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

Fixing globs in routes #793

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

aaronpowell
Copy link
Contributor

This pull request includes changes to improve the behavior of the globToRegExp function in the src/core/utils/glob.ts file. The function now correctly interprets the * character as a wildcard and escapes the . character to match a literal dot. Additionally, the expected result in the test case for globToRegExp was modified to reflect the updated behavior of the function.

Main changes:

  • src/core/utils/glob.ts: Modified the globToRegExp function to correctly interpret the * character as a wildcard and escape the . character to match a literal dot.
  • src/core/utils/glob.spec.ts: Modified the expected result in the test case for globToRegExp to include the escaped dot character (\.) to match the updated behavior of the function.

Fixes #792

Improved the string replacement to generate the regex (such as leaving the . in for extensions)
Updated tests to understand the new regex structure
@@ -31,7 +31,7 @@
}
}

return glob.replace(/\//g, "\\/").replace("*.", ".*").replace("/*", "/.*");
return glob.replace(/\//g, "\\/").replace(".", "\\.").replace("*", ".*");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of "*".
@@ -31,7 +31,7 @@
}
}

return glob.replace(/\//g, "\\/").replace("*.", ".*").replace("/*", "/.*");
return glob.replace(/\//g, "\\/").replace(".", "\\.").replace("*", ".*");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wildcard routes aren't supported properly in config
1 participant