diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-03-29 15:40:20 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-03-29 16:21:31 +0200 |
commit | ae39d47bce33f33a5854c44fc3c264787ecfd1bd (patch) | |
tree | 371b799bb7688c3f7530129327d2b49e3dcc6f64 /container-core | |
parent | 259e35ea3aea20a639a1870cfb9a6232a9521f51 (diff) |
Remove unused optionalPrefix
Diffstat (limited to 'container-core')
-rw-r--r-- | container-core/src/main/java/com/yahoo/restapi/Path.java | 15 | ||||
-rw-r--r-- | container-core/src/test/java/com/yahoo/restapi/PathTest.java | 13 |
2 files changed, 1 insertions, 27 deletions
diff --git a/container-core/src/main/java/com/yahoo/restapi/Path.java b/container-core/src/main/java/com/yahoo/restapi/Path.java index 45312f8ec15..00a47e6ddf2 100644 --- a/container-core/src/main/java/com/yahoo/restapi/Path.java +++ b/container-core/src/main/java/com/yahoo/restapi/Path.java @@ -3,7 +3,6 @@ package com.yahoo.restapi; import java.net.URI; import java.net.URLDecoder; -import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; @@ -26,16 +25,12 @@ import java.util.stream.Stream; * Note that for convenience in common use this has state which changes as a side effect of each matches * invocation. It is therefore for single thread use. * - * An optional prefix can be used to match the path spec against an alternative path. This - * is used when you have alternative paths mapped to the same resource. - * * @author bratseth */ public class Path { // This path private final String pathString; - private final String optionalPrefix; private final String[] elements; // Info about the last match @@ -43,12 +38,6 @@ public class Path { private String rest = ""; public Path(URI uri) { - this(uri, ""); - } - - // TODO (freva): Remove, used by factory - public Path(URI uri, String optionalPrefix) { - this.optionalPrefix = optionalPrefix; this.pathString = uri.getRawPath(); this.elements = Stream.of(this.pathString.split("/")) .map(part -> URLDecoder.decode(part, StandardCharsets.UTF_8)) @@ -103,9 +92,7 @@ public class Path { * @return true if the string matches, false otherwise */ public boolean matches(String pathSpec) { - if (matchesInner(pathSpec)) return true; - if (optionalPrefix.isEmpty()) return false; - return matchesInner(optionalPrefix + pathSpec); + return matchesInner(pathSpec); } /** diff --git a/container-core/src/test/java/com/yahoo/restapi/PathTest.java b/container-core/src/test/java/com/yahoo/restapi/PathTest.java index 865c8976c56..0deb27ae0f2 100644 --- a/container-core/src/test/java/com/yahoo/restapi/PathTest.java +++ b/container-core/src/test/java/com/yahoo/restapi/PathTest.java @@ -15,19 +15,6 @@ import static org.junit.Assert.assertEquals; public class PathTest { @Test - public void testWithPrefix() { - // Test that a path with a prefix matches spec without the prefix - Path path = new Path(URI.create("/ball/a/1/bar/fuz"), "/ball"); - assertTrue(path.matches("/a/{foo}/bar/{b}")); - assertEquals("1", path.get("foo")); - assertEquals("fuz", path.get("b")); - - // Also test that prefix does not cause false matches - assertFalse(path.matches("/ball/a/{foo}/zoo/{b}")); - } - - - @Test public void testPath() { assertFalse(new Path(URI.create("")).matches("/a/{foo}/bar/{b}")); assertFalse(new Path(URI.create("///")).matches("/a/{foo}/bar/{b}")); |