Skip to content

Commit

Permalink
Merge pull request #556 from gabriel-farache/fix_urlpattermatcher
Browse files Browse the repository at this point in the history
Fix UrlPatternMatcher not matching parameters in path containing "-" character
  • Loading branch information
fjtirado committed Nov 8, 2023
1 parent d8363d7 commit 2a358c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
*/
public class UrlPatternMatcher {
// Finds parameters in the URL pattern string.
private static final String URL_PARAM_REGEX = "\\{(\\w*?)\\}";
private static final String URL_PARAM_REGEX = "\\{(\\S*?)\\}";

// Replaces parameter names in the URL pattern string to match parameters in URLs.
private static final String URL_PARAM_MATCH_REGEX = "\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ private static Stream<Arguments> providePathsThatMatch() {
Arguments.of("/{id}/pets/{id2}", "/1/pets/2?q=1&q2=2"),
Arguments.of("/{id}/{foo}/{id2}", "/1/2/3?q=1&q2=2"),
Arguments.of("/{id}/{foo}/{id2}", "/1/2/3"),
Arguments.of("/v2/pets/{id}", "/v2/pets/1"));
Arguments.of("/v2/pets/{id}", "/v2/pets/1"),
Arguments.of("/pets/{pet-id}/types/{type-id}", "/pets/1/types/2"));
}

}

0 comments on commit 2a358c7

Please sign in to comment.