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: wildcard match does not escape special regex characters #106

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

skwasjer
Copy link
Owner

@skwasjer skwasjer commented Sep 5, 2024

F.ex.:

path/file.jpg?width=* was previously converted to a regex @"^(path/file.jpg?width=).*". This has a few problems:

  • the . (dot) in the filename matches any character in that position, not just the dot.
  • the ? makes the preceding g in jpg an optional character so jp matches just as well. In fact path/file.jpg?width=123 would not actually match because after the optional g, the w is now expected.

All special regex characters are now escaped, iow. the above example would be: @"^(path/file\.jpg\?width=).*"

@skwasjer skwasjer added the bug Something isn't working label Sep 5, 2024
Copy link

sonarcloud bot commented Sep 5, 2024

@skwasjer skwasjer merged commit de01038 into main Sep 5, 2024
12 checks passed
@skwasjer skwasjer deleted the fix/escape_regex_special_chars branch September 5, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant