Refine UriTemplate match pattern

The match/matches methods of UriTemplate use a regex with (.*) in place
of URI variables, which work fine except in the end where such a
pattern can match greedily more than one segment.

This commit updates the regex to use ([^/]*) instead since URI
variables are only meant to be used within a single path segment.

Issue: SPR-16169
This commit is contained in:
Rossen Stoyanchev
2018-01-11 16:36:35 -05:00
parent 84b8ceca0f
commit c60313de3f
2 changed files with 9 additions and 7 deletions

View File

@@ -212,7 +212,7 @@ public class UriTemplate implements Serializable {
String variable = builder.toString();
int idx = variable.indexOf(':');
if (idx == -1) {
pattern.append("(.*)");
pattern.append("([^/]*)");
variableNames.add(variable);
}
else {