-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Correct trailing slash redirection behavior? #29287
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
Since “/foo/“ is not an excact match I would assume it matches b. If route b did not exist I would like it to match a. Answer: option 3 is the correct behavior. |
I agree with @Nyholm. This matches other redirection logic we have. First match exact matches, then fall back to redirect. Otherwise it would be inconsistent with Given two routes (in order):
for URL |
Interesting because on Slack I read opposite arguments and they make sense also:
The least surprise principle would hint me at "a" also. Technically, symfony.com would be affected by changing from "a" to "b". But that not obvious, that's why I asked :) |
The "correct behavior" term is loaded here: does it mean "technically correct" or "correct as expected"? If you want to be technically correct, I agree with @Nyholm, it's not a full match. If you want to be working as (IMO) expected, then a) should match. Again, if you're saying the trailing slash is ignored, then it's perceived as non-significant and having |
I disagree with @Nyholm. In Symfony apps, if your route is |
Imagine letter addressed with "street" prefix/suffix and without it - it's still the same address, deliverable (well, probably not always). Or maybe semicolons in Javascript - it's the same instruction whether you put And IMO there shouldn't be any redirect, just display the same content under both URLs (like Github does). |
The arguments for a) make sense to me, here is a fix: #29297 |
/foo/ and /foo are not the same URIs. For this reason it does not make sense to match a different route than the one that actually matches. Also if you generate a the uri for "b" with name=foo, you will get Furthermore, changing the behavior makes the route matching dependent on whether redirectable url matcher is implement or not because you will get different results for the same input. |
@Tobion If you define dynamic routes with params that conflict with other routes, it's your fault. Trailing slash doesn't matter. Look at this issue, it's displayed under both URIs because its namespace is unique. |
…ctableUrlMatcher (nicolas-grekas) This PR was merged into the 3.4 branch. Discussion ---------- [Routing] fix trailing slash redirection when using RedirectableUrlMatcher | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29287 | License | MIT | Doc PR | - This fixes #29287 by considering that the behavior of the dumped matcher is the correct one: lower priority routes never impact previous ones. I think it's what makes the most sense because that's what requires the most local knowledge to understand what's going on (ie that's the less surprising behavior). Commits ------- dc4c3f6 [Routing] fix trailing slash redirection when using RedirectableUrlMatcher
Thank you for the discussion and the input. |
I have route |
@murnieza please open a new issue |
Uh oh!
There was an error while loading. Please reload this page.
We spotted the following:
Given two routes (in order):
/foo/
/{name}
for URL
/foo
, a redirectable router matcher:What is the correct behavior?
The text was updated successfully, but these errors were encountered: