aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-12-21 13:34:28 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-12-21 13:34:28 +0100
commit9dc52312a5cd10d79cad13634381ea1eb5c7f0d3 (patch)
tree108ee45a414b8302fdd71d3d5867de399b787f32 /jdisc_core
parentb962664eb83a80d7a3f1e8b0284796d421a253c8 (diff)
Require host to be present in URIs to match
Diffstat (limited to 'jdisc_core')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java3
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java26
2 files changed, 2 insertions, 27 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java
index 84a7e8066f9..aedd641a785 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java
@@ -108,7 +108,8 @@ public class UriPattern implements Comparable<UriPattern> {
if (schemeMatch == null) {
return null;
}
- GlobPattern.Match hostMatch = host.match(nonNullOrBlank(uri.getHost()));
+ GlobPattern.Match hostMatch = uri.getHost() == null ? null
+ : host.match(uri.getHost());
if (hostMatch == null) {
return null;
}
diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java
index 4b196265e80..da48503729d 100644
--- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java
+++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java
@@ -124,32 +124,6 @@ public class UriPatternTestCase {
}
@Test
- public void requireThatUriWithoutHostDoesNotThrowException() {
- String schemeOnly = "scheme:schemeSpecificPart";
- String schemeAndPath = "scheme:/path";
- String pathOnly = "path";
- String pathOnlyWithSlash = "/path";
-
- UriPattern pattern = new UriPattern("scheme://host/path");
- assertNotMatch(pattern, schemeOnly);
- assertNotMatch(pattern, schemeAndPath);
- assertNotMatch(pattern, pathOnly);
- assertNotMatch(pattern, pathOnlyWithSlash);
-
- pattern = new UriPattern("scheme*://host*/path*");
- assertNotMatch(pattern, schemeOnly);
- assertNotMatch(pattern, schemeAndPath);
- assertNotMatch(pattern, pathOnly);
- assertNotMatch(pattern, pathOnlyWithSlash);
-
- pattern = new UriPattern("*://*/*");
- assertMatch(pattern, schemeOnly, Arrays.asList("scheme", "", ""));
- assertMatch(pattern, schemeAndPath, Arrays.asList("scheme", "", "path"));
- assertMatch(pattern, pathOnly, Arrays.asList("", "", "path"));
- assertMatch(pattern, pathOnlyWithSlash, Arrays.asList("", "", "path"));
- }
-
- @Test
public void requireThatUriWithoutPathDoesNotThrowException() {
UriPattern pattern = new UriPattern("scheme://host/path");
assertNotMatch(pattern, "scheme://host");