-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Trailingslash has a wrong ranking and creates empty params in array if after a wildcard parameter #2379
Comments
The ranking of a trailing slash is an intended behavior. |
Sorry, that's not an option I'm using the Here are the regex and scores
As you can see the strict option is not working properly in this case
It might be but it's not a good one in certain cases, a trailing slash should rank lower than a slash that is not trailing if the The only way this works is with no trailingslash or by relying on a bug (#1301 (comment)) by using another regex than |
Having redundant paths will always yield issues in routing and should be avoided. Using |
It shouldn't, that's never been a problem when routing uses the user provided order instead of computing a score, but if it computes a score then it should do so correctly or provide us with the option to change the score of a route manually to avoid this being an issue.
That's basically suggesting another feature because the core feature of the router is not working properly, I don't see how a server redirect when vue router does client side routing would work properly, I could have this issue with any other things than pagination that wouldn't be suited to query args for example Btw if you start toggling on and off strict mode on this https://paths.esm.dev/?p=AAMeJYyBwQIJDJDWgQvuTXABS8EAfA6gKoD4AaAEgBoIKEV0sHR1bzqPAPBZdXstpCEAAA..&t=/character/buddy/the/one/pet/dog#, you will also see a similar but different issue on path ranking that causes the same problem without trailing slash, the strict bonus should not apply at all or be negative
Thanks, at least I have a workaround so it's a less pressing issue. - I'm talking about the fact that From what I gathered it just seems like an oversight there with trailingslashes being considered as another root segment, shouldn't this just happen for the actual root path
|
All in all I can submit a PR for bug 1 which is optional or repeated params lazyness is being overwritten by being wrapped (by checking the presence of (+|*|?)? in the regex and appending another And another PR for the trailingslash issue I have no problem spending a bit of time for that. But they should be regarded as what they are, which is bugs. I only have a problem spending time on a PR for nothing (that will never be accepted because it is "intended behavior") |
That's totally understandable.
Maybe there is a differentiation to be made between
I see. Unless the current behavior exposes a ranking issue, I doubt any effort will be made to break the current workaround, especially knowing now that it is a workaround. It's great you bring it up thought |
That is perfectly reasonable to me, my PR will likely not arrive before 2 weeks and there will be no rush on this. And if you deem the ranking to be too different on the trailingslash issue I would have no problem if it got sent to the next major (I will included tests from the linked issues otherwise so I'm sure it won't be a breaking change, I think option 1 would be the most correct way because trailingslash in the route definition should not change the score at least in non strict mode I can also mix and match option 1 in non strict mode and option 2 in strict I could also give the option to users to hardcode route priority in a minor and the ranking change in a major to still allow this kind of issues to be worked around until a few years when the next major releases |
Reproduction
https://play.vuejs.org/#eNqtVV1P2zAU/SteNqnt1tqlQzxkoWNDaGzaB2LTXpY9pImbBhLbsh0oivrfd22niQsFXibUNrn33ONzfY9NE1RJwfCVCsKgqASXGjUolTTR9IMQaIOWkldocFPTQcw6gOS1prLLYuICPcTUbnOJENjVx6xjHsJnFDOEcK3o0JW794rXTA8HL6FsMArGQVsO+iJNK1FC/dwAo9XB/JyWJTeLvYgIvNqwsD/woLTkLJ+f1lJSpp1mJBK9CiPS5lDToFc2gZd1WV5AEm02loY4noglN1vCS6vya8GukebHcUDiYP6JwzM65xWNSJ9/tCJZpCSjy75SU6WfqQxtacOSioZoYAomIsnpYAzNyKRSIWowxq4LFzGZHMAz6MVfCN0W0KDJPVgyIttGI2OIXRm/C3qLSItr0xHxpgGvKpWF0EhRXZud66wC47UkvpUmrV3egSE4A11uNscdeDiCFEzJcs7BBK4A6z02/UYrLu/OC6XhZ9wGne59axqxLYOZmm1t69RtoLXr1ssLqNzBdZHO13RtoV43EtrxtQwbs30rJzPcp304GhuIrYah/nEjaJxl0YDAwFMOkhi4OezFb2yVAXoOseZwZaF5H+LX70ev71H0je3l6F32kMikSGi+h3GcvRk9w/wXvjdwvGGS/h6bM+37BpUJy8HrWoFtPQNYg907/LP5lgmO/mzXkLDMzoieWed/enW/1E5NqxV2uvEPrLlzdvU7TZMqEXA3cwYdWP/EbQKEw7F3Q4uDXqYJx8FKa6FCQmomrnMMcyE94uQQv8VTkoHnvCimqposJL9V8HwF7K0h4uAEQHBl3WjOSzVJRPHYEg+AJ0f4CB+QslgQYCcFy+jachtqaHgDbWoFm7os8ntNGisVJZU/hC5g03eaTeDKv/1iY1rWtBOarmh6vSd+pdZO8oWk0N0N9ZrTicypdumzn9/pGp67ZMWzugT0E8lLqnhZG40O9rFmGcj2cFbtZzuzguW/1NlaU6a2TRmhdjcs3g7y9InWe7lv8aG3i0rflVThVJnrEe7xMTKXtKtbcJlRCf8LxBqB2CJDL6fTKVgWAUjmBZssuNa8CtHBVKxtXCRZBmK7CKwSM6BFc5SgN/CxxG11SZdw4H3kauav3NP3AtI09QSEaAp/s5Yh2PwD2IzlHA==
Steps to reproduce the bug
Expected behavior
Without a trailing slash the ranking is correct, I think the trailingslash should have a lower rank than a regex
https://paths.esm.dev/?p=AAMeJUyB3A7ACAROgDYMTAHuJXIFqHQAUAFACTg_OQA5INikft_qADWgAQVDQMk8w6RBgNwSAIA.&t=/en/brands/abcd/efh/page/2#
Actual behavior
With a trailing slash now the ranking is wrong and the second route can never be matched https://paths.esm.dev/?p=AAMeJUyB3A7ACAROgDYMTAHuJXIFqHQAUAFACTg_OQA5INikft_qADWg4AUBBfMMSSMghySCcrsAAA..&t=/en/brands/abcd/efh/page/2#
Additional information
I think the trailingslash should be discarded from the params list because it's in any case optional with vue router
The ranking should also be changed so that a trailingslash doesn't alter the ranking
Related #1300
#1123
The text was updated successfully, but these errors were encountered: