diff options
author | jonmv <venstad@gmail.com> | 2023-10-06 16:30:22 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-10-06 16:30:22 +0200 |
commit | 03b7ce7d31bfbcb130da21a511485a51c43baf7f (patch) | |
tree | cfc8b1c725ea72ce8bddc7c43ff8fc10ec6485a2 /vespajlib/src/main/java/com/yahoo/net/Url.java | |
parent | 1857991cf335f31fca0a499f72fbaa83cb47dd14 (diff) |
Correct parenthesis counting, remove unnecessary nesting and escapes
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/net/Url.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/net/Url.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/net/Url.java b/vespajlib/src/main/java/com/yahoo/net/Url.java index e6e7512c9f8..81959f58b6f 100644 --- a/vespajlib/src/main/java/com/yahoo/net/Url.java +++ b/vespajlib/src/main/java/com/yahoo/net/Url.java @@ -10,9 +10,9 @@ import java.util.regex.Pattern; public class Url { private static final Pattern pattern = Pattern.compile( - //12 3 456 7 8 9ab c d e f g h i j - // 2 1 6 87 5 c b ed a4 f hg ji - "^(([^:/?#]+):)?(//((([^:@/?#]+)(:([^@/?#]+))?@))?(((\\[([^\\]]+)\\]|[^:/?#]+)(:([^/?#]+))?)))?([^?#]+)?(\\?([^#]*))?(#(.*))?"); + //12 3 45 6 7 89 a b c d e f g h + // 2 1 5 76 4 a 9 cb 8 d fe hg + "^(([^:/?#]+):)?(//(([^:@/?#]+)(:([^@/?#]+))?@)?((\\[([^]]+)]|[^:/?#]+)(:([^/?#]+))?))?([^?#]+)?(\\?([^#]*))?(#(.*))?"); private final String image; private final int schemeBegin; private final int schemeEnd; @@ -122,17 +122,17 @@ public class Url { if (!matcher.matches()) { throw new IllegalArgumentException("Malformed URL."); } - String host = matcher.group(12); + String host = matcher.group(10); if (host == null) { - host = matcher.group(11); + host = matcher.group(9); } if (host == null) { - host = matcher.group(9); + host = matcher.group(8); } - String port = matcher.group(14); - return new Url(matcher.group(2), matcher.group(6), matcher.group(8), host, - port != null ? Integer.valueOf(port) : null, matcher.group(15), matcher.group(17), - matcher.group(19)); + String port = matcher.group(12); + return new Url(matcher.group(2), matcher.group(5), matcher.group(7), host, + port != null ? Integer.valueOf(port) : null, matcher.group(13), matcher.group(15), + matcher.group(17)); } public int getSchemeBegin() { |