Skip to content

Commit

Permalink
[RESTEASY-1878] UriBuilder.fromPath() fails on regexp template parame…
Browse files Browse the repository at this point in the history
…ter (#1511)

Thanks!
  • Loading branch information
rnetuka authored and asoldano committed May 21, 2018
1 parent c24309c commit 2b4765d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Expand Up @@ -86,8 +86,8 @@ public UriBuilder clone()
return impl;
}

public static final Pattern opaqueUri = Pattern.compile("^([^:/?#]+):([^/].*)");
public static final Pattern hierarchicalUri = Pattern.compile("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
public static final Pattern opaqueUri = Pattern.compile("^([^:/?#{]+):([^/].*)");
public static final Pattern hierarchicalUri = Pattern.compile("^(([^:/?#{]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
private static final Pattern hostPortPattern = Pattern.compile("([^/:]+):(\\d+)");
private static final Pattern squareHostBrackets = Pattern.compile( "(\\[(([0-9A-Fa-f]{0,4}:){2,7})([0-9A-Fa-f]{0,4})%?.*\\]):(\\d+)" );

Expand Down
Expand Up @@ -101,6 +101,18 @@ public void uriBuilderTest() throws Exception {
builder = builder.resolveTemplates(values);
template = builder.toTemplate();
Assert.assertEquals(ERROR_MSG, template, "http://localhost/x/y/z?name=42");

// RESTEASY-1878 - test if regex templates work
// see javax.ws.rs.core.UriBuilder class description for info about regex template parameters
builder = UriBuilder.fromUri("{id: [0-9]+}");
Assert.assertEquals(new URI("123"), builder.build("123"));

builder = UriBuilder.fromUri("{id: [0-9]+}");
Assert.assertEquals(new URI("abcd"), builder.build("abcd"));

builder = UriBuilder.fromUri("/resources/{id: [0-9]+}");
Assert.assertEquals(new URI("/resources/123"), builder.build("123"));
// end of RESTEASY-1878
}

// test587
Expand Down

0 comments on commit 2b4765d

Please sign in to comment.