-
-
Notifications
You must be signed in to change notification settings - Fork 364
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 route param parsing when the param begins with just one letter #686
base: main
Are you sure you want to change the base?
Fix route param parsing when the param begins with just one letter #686
Conversation
@ahoseinian Hi! I've also found that the existing regex does not detect all path params within route path string. One-letter params (like /({[a-zA-Z]([-_.]?[a-zA-Z0-9])*})|(:[a-zA-Z]([-_.]?[a-zA-Z0-9])*:?)/g There are other improvements here:
|
hi @nicky1038, Thanks for the suggestion. I wanted to change this minimally so not to break anything, but as the tests are all passing, I think this should be fine. just one small problem I noticed with your version of the regex. it would not find parameters with two underlines. which I guess it is unlikely but as the previous version would I wouldn't want to break that. what I mean is for example a param like so I will change this to: let me know if you have any suggestions. |
@ahoseinian Trying to change as little code as possible in order to prevent it from breaking is a very rational idea. However, the case of My regex doesn't find My thoughts about your latest suggestion:
So depending on what we decide, it would be either /({[a-zA-Z]([-_.]*[a-zA-Z0-9])*})|(:[a-zA-Z]([-_.]*[a-zA-Z0-9])*:?)/g or /({[a-zA-Z]([a-zA-Z0-9-_.])*})|(:[a-zA-Z]([a-zA-Z0-9-_.])*:?)/g I'd prefer the first option. |
accourding to this suggestion acacode#686 (comment)
For example if the param was i_key the current regex would not find it as a variable. it was only working for the params with more than one letter before either `.` `-` or `_`. the fix should allow to find params with only one letter at begninng.
accourding to this suggestion acacode#686 (comment)
9be7ea8
to
7a8f234
Compare
@nicky1038 totally agree: updated the regex to your suggested one: /({[a-zA-Z]([-_.]*[a-zA-Z0-9])*})|(:[a-zA-Z]([-_.]*[a-zA-Z0-9])*:?)/g |
@smorimoto saw that you have put some commits recently. maybe you can take a look at this also :) |
Could you rebase to latest main branch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 4 changed files in this pull request and generated no suggestions.
Files not reviewed (1)
- tests/spec/extractRequestParams/schema.json: Language not supported
Comments skipped due to low confidence (3)
tests/spec/extractRequestParams/schema.ts:475
- [nitpick] The variable name 'iKey' is ambiguous. It should be renamed to 'authentiqKey'.
iKey = {
tests/spec/extractRequestParams/schema.ts:483
- [nitpick] The variable name 'iPk' is ambiguous. It should be renamed to 'authentiqKeyId'.
iKeyDetail: (iPk: string, params: RequestParams = {}) =>
src/schema-routes/schema-routes.js:113
- Ensure that the new regex pattern is covered by tests, specifically for route parameters that begin with a single letter.
/({[a-zA-Z]([-_.]*[a-zA-Z0-9])*})|(:[a-zA-Z]([-_.]*[a-zA-Z0-9])*:?)/g,
For example if the param was i_key the current regex would not find it as a variable. it was only working for the params with more than one letter before either
.
-
or_
. the fix should allow to find params with only one letter at begninng.