-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Updated to path-to-regexp@3.0.0 #42
Conversation
The test has been fixed for quite a while on master. I can see this PR cannot even be merged by GitHub, so I think you have it based off some stale code. |
Yep, forgot to update my forked version. Will do that now, sorry. |
And yes, bumping would be 2.0, which is fine :) Can we get a migration guide written up for users to understand how to translate their routes from the old style to the new style to add with this? I think that's really the only blocker. |
8b77a8b
to
868ae16
Compare
Based on the tests there is one breaking use case because I think @blakeembrey could probably provide a more comprehensive list of changes, but then I would be happy to write them up into a guide. |
I've written the differences a bundle of times, I think the most comprehensive was for Doug in the Express repo. |
The tests in this module do not actually exercise the different syntaxes currently, so knowing what broke is not possible from this test suite (for example, I don't see you adding any tests for all the new syntax in 1.x, continuing that trend ;) ). |
I can add a bunch more tests for the supported syntax if you like. It would seem weird to test features of For documentation, is what is listed here comprehensive? Can we just do a link here to that section? |
I cannot find any more docs that what is in that readme. So I added them here. As for tests, I think testing dependencies is not a great decision. But I understand the reasoning here because Either way, this update does not make us worse off. So IMO it could be merged. |
I agree that extensively testing dependencies is not great. But sometimes I still think that at least basic tests of the main features of a dependency as they are directly exposed through the interface of this module helps flush out accidental regressions upstream and can help us understand if we can bump a major in that dep without bumping our dep. |
Thanks for starting on the migration guide :) ! One thing I noticed right away is that the migration guides doesn't provide any guidance on whatever the reason the tests were changed in order to up this dep? |
9a4a859
to
6d0dba6
Compare
I added tests, I think they should be satisfactory, hits the major points. Let me know if there is anything else you would like me to add. As for the guide thing, I am really unsure what the core changes were, so I don't actually know what to add. I am happy to add what other people post here, or let them add to this PR as necessary. |
The latest version is 2.0.0. |
Yea, so we still need a migration guide from the respect of this module. Users need to understand what routes they need to change and how during the upgrade or they'll never be able to upgrade their apps successfully. It seems the 2.0 release breaks even more tha. The 1.0, which is fine, but I'm not even clear on how to upgrade the route paths for the transition. |
Just a note, but compatibility is still listed in https://github.com/pillarjs/path-to-regexp#compatibility-with-express--4x. The primary difference between 1.x and 2.x was that I needed to drop support for |
6d0dba6
to
e49c42b
Compare
Ok, I just updated this PR. But it appears that something also changed with the handling of trailing slashes. @blakeembrey Know what I need to do to fix the two tests I added |
e49c42b
to
2118d04
Compare
I just updated the upgrade guide as well. Any thoughts or changes necessary? |
Does this include the changes between 0.1.x and 2.x or just 0.2.x and 2.x? What were the differences between 0.1.x and 0.2.x, again? |
AFAIK, this guide is ALL of the changes since |
README.md
Outdated
The main change is the update to `path-to-regexp@2.0.0`, which has a few breaking changes: | ||
|
||
- No longer a direct conversion to a RegExp with sugar on top - it's a path matcher with named and unnamed matching groups | ||
- It's unlikely you previously abused this feature, it's rare and you could always use a RegExp instead |
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.
We should explain how to know if you are using the feature rather than editorial that "you're probably not using it"
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.
@blakeembrey I copied this from your readme. Can you give me a short blurb to help explain what this means?
Like what is an example "abuse of this feature"?
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.
Sure. It's anywhere someone is abusing stuff like /\\d+
outside of a matching group (e.g. instead of /(\\d+)
). It's possible it's used in places today, but wouldn't be too useful since it wouldn't result in a match the user could use.
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.
If you end up coming up with a better or more succinct explanation, happy to replace the one in the README 😄
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.
You'd be surprised what people do with these routes. Express 4.16.1 is a release just because it seemed to be popular to do something thag shouldn't work, but did.
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.
Question: What specifically does this mean?
Parameters have suffixes that augment meaning -
*
,+
and?
. E.g./:user*
Couldn't we always use those suffixes? How are they different from 0.1.7
to 2.0.0
?
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.
No, 0.x never had a concept of "suffixes". There's places where it happened to work because everything is treated as a regexp with based search and replace. E.g. /*
became /(.*)
in search and replace (that's the reason you can't use *
in Express.js). It also means that, yes, stuff like /:user?
might have worked but purely because of the search and replace implications and definitely not consistently (for instance, /:test*
never would have done anything expected).
Note: I haven't tested the specific examples above, but it's possible a comparison (0.x -> 2.x) might be the easiest way to understand the differences.
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.
Yeah that is probably why those worked for me :)
I was actually thinking it might be nice to update the demo app to support multiple versions, which might be helpful for people to discover the differences for their routes. Maybe I can work on that next.
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.
Ok, got a PR for that feature in the demo app: ForbesLindesay/express-route-tester#11
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.
If you all need to see the differences in the versions you can view it here until the PR is merged: https://wesleytodd.github.io/express-route-tester/
README.md
Outdated
- No longer a direct conversion to a RegExp with sugar on top - it's a path matcher with named and unnamed matching groups | ||
- It's unlikely you previously abused this feature, it's rare and you could always use a RegExp instead | ||
- All matching RegExp special characters can be used in a matching group. E.g. `:user(*)` needs to become `/:user(.*)` | ||
- Other RegExp features are not support - no nested matching groups, non-capturing groups or look aheads |
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.
Typo in "support"
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.
fixed
@wesleytodd See https://github.com/pillarjs/path-to-regexp/blob/master/History.md#300--2019-01-13. Specifically it was the treatment around delimiter tokens (e.g. the character before |
9d829da
to
a5a94f3
Compare
Awesome, so I updated to |
Too many versions too fast :P @blakeembrey Should we update this to |
@wesleytodd See https://github.com/pillarjs/path-to-regexp/releases. 4.0 was for ES2015, 5.0 was because I added a feature(s) I shouldn't have. |
Ahh, I was wondering about that quick jump from 3 to 5. There was too many notifications for me to read all of them and follow. Could you summarize the changes so we can add it to the readme and docs? I will update the PR from there. |
@wesleytodd The only mentionable feature is support for nested non-capturing regex groups, e.g. Edit: Technically someone could be doing |
Final release I intend to make for this library is https://github.com/pillarjs/path-to-regexp/releases/tag/v6.0.0, which reverts some of the confusion I added in v3 and adds an alternative ( |
console.log(req.params) // {'foo': 'bar'} | ||
``` | ||
|
||
#### Partial matching, prefer escaping delimiter |
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.
This section shouldn't be relevant anymore. However, you can make the example /user{s}?
if you wanted to.
@@ -645,7 +645,7 @@ describe('Router', function () { | |||
it('should work following a partial capture group', function (done) { | |||
var cb = after(2, done) | |||
var router = new Router() | |||
var route = router.route('/user(s)?/:user/:op') | |||
var route = router.route('\\/user(s)?/:user/:op') |
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.
Should be good to revert this.
this needs a rebase. anything else? |
This needs nothing at this time as Wes rebased it on a separate branch instead of within the PR. Github will close it automatically after I move the changes back to the PR branch. |
So it looks like I don't have permission to push up to the remote branch. This is just a heads-up, so the changes will end up landing on the 2.0 branch, and will end up stating this PR is "closed" instead of "merged". |
@dougwilson - can you clarify what does this mean? the PR is originally destined for 2.0 branch itself, right? or is there a change? or is it that the landing will be same (to 2.0) but the github web interface will show it as closed, while the code would have landed? |
This PR has merge conflicts that must be resolved, and even has an incomplete section in the migration guide among other changes that are needed. I am working on the changes, but I get permission denied trying to push them up to the PR branch. Since I cannot push them into this PR first, landing this PR + changes onto 2.0 will cause GitHub to mark this PR as "closed" instead of "merged", is all. |
All the changes here + various fix ups has landed into the |
This would probably be a major version bump for router since the path matching semantics are so different.
Also. you will notice a change in the tests. I opened a separate issue to discuss, #41.