Fix failing test (after previous commit)

This commit is contained in:
Rossen Stoyanchev 2017-06-15 11:07:39 -04:00
parent 97917aa57d
commit 53e8ebe6a6
2 changed files with 7 additions and 0 deletions

View File

@ -190,10 +190,14 @@ class DefaultPathSegmentContainer implements PathSegmentContainer {
}
static PathSegmentContainer subPath(PathSegmentContainer container, int fromIndex, int toIndex) {
if (fromIndex == toIndex) {
return EMPTY_PATH;
}
List<PathSegment> segments = container.pathSegments();
if (fromIndex == 0 && toIndex == segments.size()) {
return container;
}
Assert.isTrue(fromIndex < toIndex, "fromIndex: " + fromIndex + " should be < toIndex " + toIndex);
Assert.isTrue(fromIndex >= 0 && fromIndex < segments.size(), "Invalid fromIndex: " + fromIndex);
Assert.isTrue(toIndex >= 0 && toIndex <= segments.size(), "Invalid toIndex: " + toIndex);

View File

@ -36,6 +36,9 @@ public class DefaultRequestPathTests {
// no context path
testRequestPath("/a/b/c", "", "/a/b/c", false, true, false);
// context path only
testRequestPath("/a/b", "/a/b", "", false, true, false);
// empty path
testRequestPath("", "", "", true, false, false);
testRequestPath("", "/", "", true, false, false);