Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UrlPatternMatcher not matching parameters in path containing "-" character #556

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

gabriel-farache
Copy link
Contributor

@gabriel-farache gabriel-farache commented Nov 8, 2023

Fixes: #555

The UrlPatternMatcher is not matching URLs with path parameters containing the "-" character.
The following error is throw when using such URL:

java.util.regex.PatternSyntaxException: Illegal repetition near index 7
/pets/{pet-id}/types/{type-id}(?:\?.*?)?$

The root cause is the following pattern: private static final String URL_PARAM_REGEX = "\\{(\\w*?)\\}";.
Here the \w is not considering the "-" character as part of a word thus not matching.

The "-" being an authorized character in the URL parameter, the pattern used shall match.

By using \S instead, the pattern is matching the parameters as expected.


Please make sure that your PR meets the following requirements:

  • You have read the contributors guide
  • Your code is properly formatted according to our code style
  • Pull Request title contains the target branch if not targeting main: [0.9.x] Subject
  • Pull Request contains link to the issue
  • Pull Request contains link to any dependent or related Pull Request
  • Pull Request contains description of the issue
  • Pull Request does not include fixes for issues other than the main ticket
How to backport a pull request to a different branch?

In order to automatically create a backporting pull request please add one or more labels having the following format backport-<branch-name>, where <branch-name> is the name of the branch where the pull request must be backported to (e.g., backport-quarkus2 to backport the original PR to the quarkus2 branch).

NOTE: backporting is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another.

Once the original pull request is successfully merged, the automated action will create one backporting pull request per each label (with the previous format) that has been added.

If something goes wrong, the author will be notified and at this point a manual backporting is needed.

NOTE: this automated backporting is triggered whenever a pull request on main branch is labeled or closed, but both conditions must be satisfied to get the new PR created.

Copy link
Contributor

github-actions bot commented Nov 8, 2023

🎊 PR Preview 0a75a3b has been successfully built and deployed. [See the documentation preview here](https://quarkus-openapi-generator-preview-pr-556
.surge.sh).

@fjtirado fjtirado merged commit effa80d into quarkiverse:main Nov 8, 2023
10 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 8, 2023
Fix UrlPatternMatcher not matching parameters in path containing "-" character
@hbelmiro
Copy link
Contributor

hbelmiro commented Nov 8, 2023

@allcontributors please add @gabriel-farache for code and test

Copy link
Contributor

@hbelmiro

I've put up a pull request to add @gabriel-farache! 🎉

hbelmiro pushed a commit that referenced this pull request Nov 8, 2023
Fix UrlPatternMatcher not matching parameters in path containing "-" character

Co-authored-by: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UrlPatternMatcher not matching parameters in path containing "-" character
3 participants