-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Path matching semantics update #2057
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
Comments
|
@jonathanong Sorry, these were incredibly trivial examples - let me think of something more complex and realistic.
|
i don't see any value and wouldn't mine deprecating them or something i'm okay with the other two gotcha's as long as they're documented. |
citiy_selection and about will just set the site_state and call next(). Control should then goto the generic renderer to display the site. However when i visit about page citiy_selection route is also executed. What is it that i am doing wrong here? |
@chirag04 Is |
@blakeembrey Yes, both info.about and home.city_selection call next so that control moves to the generic renderer. Is there a way to not execute multiple matching routes? How should i go about solving this apart from not calling next in |
@chirag04 There isn't really a way to do this without something hacky, but in reality you don't want to write routes that do fall through like that. Can you pull the function out use it in both places? |
I want to make it generic. I dont want to pull that function out and duplicate in both places. However i am using this approach for now: Instead of calling next, each about and city_selection will call render_site function. Eg:
Render site moved out of app.use wrapper into an independent module
This seems to work for now. |
Hey @blakeembrey, would you be willing to put together a list of the incompatibilities between 0.x and 1.x of |
Oh, and as an additional though, @blakeembrey, I'm not really looking for a full list of new features in 1.x (at least for this), more of what kind of paths that would be broken/behave differently between the two versions and how to fix them to work in 1.x. I hope that helps! |
Sure, I can look at putting something together. I think 99% of uses are the same, it's just the tricky edge ones (and hacks that may not have even been intended with |
There's also https://github.com/pillarjs/path-to-regexp#compatibility-with-express--4x, though it's less exhaustive. Should give you an idea on the core changes that aren't supported now though. Most changes were around consistency and proper usage of |
Yea, the tricky ones are what I'm looking for. I think the goal is just to get the best we can :) I looked at that section of the README, but it didn't seem quite what I was looking for, mainly just enough words to help people understand how to identify a route that would break. |
Things that will be broken (may be incomplete):
Advantages:
|
These changes have now landed on the 5.0 branch 👍 |
I would like to make a breaking change update to the way paths match, but I'm interested in everyones opinions before I implement any changes. My biggest gripe right now is that the special characters outside of a custom matching group restricts the characters that can be used inside of a matching group. I want to change this behaviour so only regex characters can be used inside a matching group and characters outside will be escaped.
Examples:
/test?
- currently valid, makes thet
character optional which really looks like a bug/:test(.*)
- currently invalid, periods are being escaped and asterisks are being turned into matching any character groups/(\\d+)
- currently won't be indexed properly since we don't have any regex group logic/\\*
- currently invalid, can't escape the meaning of special characters and will still become a match all routeThe text was updated successfully, but these errors were encountered: