-
-
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
There should be a simpler alternative to the(.*)?
pattern
#1301
Comments
If you don't need the array format you should just use |
Although I think we could maybe introduce a new syntax: |
(.*)*
pattern(.*)?
pattern
I was a little confused by the grouping but looking at the fiddles, I'm seeing that the slashes aren't part of the regex used for the parameters. I guess they are being handled internally, so instead of using the matchAll metacharacter you can use a character class and just include the characters you using in your route. This performs pretty well even with the greedy regex pattern. |
I would also add that the pattern should allow for lazy quantifiers, right now any param match will always be greedy and this is very problematic The previous path would work if I was allowed to add And if anything this should be the default, greedy matching makes no sense for a router https://github.com/vuejs/router/blob/main/packages/router/src/matcher/pathParserRanker.ts#L190 This should basically be replaced from |
I would point out that this opens the router to a bug where navigating will url encode the parameter Eg: You are on path |
FYI the regexp are already non greedy ( router.replace({
...router.currentRoute.value,
query: { n: Date.now() }
}) |
That's not true because our patterns are wrapped in This is the generated regex from the tool
As you can see it is greedy: And because of that page/2 goes into the wrong parameter This is what it needs to be lazy But we don't have any way to modify this quantifier because it is added by the core there Maybe we can tweak it? If the last char of the regex is a This would result in |
There also seems to be a problem in the path ranking if I split it into 2 routes with a trailing slash (which is one of our requirement) Without a trailing slash the ranking is correct, I think the trailingslash should have a lower rank than a regex Effectively I'm doomed |
You have multiple ways of handling it. Maybe a query param for the page instead of a param otherwise your routes are indeed redundant and the trailing slash makes it more specific. In your case the upcoming new custom matches could help |
Version
4.0.12
Reproduction link
jsfiddle.net
Steps to reproduce
(.*)*
patterns. For examplepath: '/:seoPath(.*)*/c/:categoryId/:facetsPath(.*)*'
(.*)*
pattern with a long path matching the pattern.This delay occurs when rendering
router-link
as well as during route navigation.This fiddle has ~20 path segments and shows a 1-second delay when loading the page or clicking the link:
https://jsfiddle.net/zcrittendon/j1fmu680/2/
This fiddle has ~30 path segments and shows shows a multi-minute delay (or browser hang) when loading the page:
https://jsfiddle.net/zcrittendon/dmzjvq56/8/
This fiddle has has ~30 path segments, but has no delay because it uses pattern
(.*)?
instead of(.*)*
https://jsfiddle.net/zcrittendon/9ze24hx7/5/
What is expected?
Router performance should not be longer than ~1 second even for very long wildcard URL paths.
What is actually happening?
Router performance is extremely long (or hands) for very long wildcard URL paths.
The text was updated successfully, but these errors were encountered: