#1802 - Allow dots in template variable names.
This commit is contained in:
@@ -50,8 +50,9 @@ import org.springframework.web.util.UriUtils;
|
||||
*/
|
||||
public class UriTemplate implements Iterable<TemplateVariable>, Serializable {
|
||||
|
||||
private static final Pattern VARIABLE_REGEX = Pattern.compile("\\{([\\?\\&#/\\.\\+\\;]?)([\\w(\\:\\d+)*%\\,*]+)\\}");
|
||||
private static final Pattern ELEMENT_REGEX = Pattern.compile("([\\w\\%]+)(\\:\\d+)?(\\*)?");
|
||||
private static final Pattern VARIABLE_REGEX = Pattern
|
||||
.compile("\\{([\\?\\&#/\\.\\+\\;]?)([\\w\\.(\\:\\d+)*%\\,*]+)\\}");
|
||||
private static final Pattern ELEMENT_REGEX = Pattern.compile("([\\w\\.\\%]+)(\\:\\d+)?(\\*)?");
|
||||
private static final long serialVersionUID = -1007874653930162262L;
|
||||
|
||||
private final TemplateVariables variables;
|
||||
|
||||
@@ -382,6 +382,14 @@ class UriTemplateUnitTest {
|
||||
.doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@Test // #1802
|
||||
void supportsDotsInVariableName() {
|
||||
|
||||
UriTemplate template = UriTemplate.of("/path/{foo.bar}");
|
||||
|
||||
assertThat(template.getVariableNames()).contains("foo.bar");
|
||||
}
|
||||
|
||||
private static void assertVariables(UriTemplate template, TemplateVariable... variables) {
|
||||
assertVariables(template, Arrays.asList(variables));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user