Skip to content
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

Static matcher #3713

Closed
wants to merge 6 commits into from
Closed

Static matcher #3713

wants to merge 6 commits into from

Conversation

iurisilvio
Copy link
Contributor

Improves #3709.

@netlify
Copy link

netlify bot commented Feb 5, 2022

✔️ Deploy Preview for vue-router-docs-v3 canceled.

🔨 Explore the source changes: 5b6ed7c

🔍 Inspect the deploy log: https://app.netlify.com/sites/vue-router-docs-v3/deploys/6202c17babf9d10007f81c8d

@iurisilvio
Copy link
Contributor Author

The failing test is #3714.

@@ -61,9 +61,7 @@ describe('Creating Route Map', function () {
'',
'/foo',
'/bar/',
'/bar',
Copy link
Member

@posva posva Feb 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should still work. Were they removed by accident?

Copy link
Contributor Author

@iurisilvio iurisilvio Feb 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed because the previous rule always match before, the strict flag is false by default.

I was not convinced about this behavior, so I wrote a test to validate it.

https://github.com/buserbrasil/vue-router/commit/c247c520d121b4847d0e9d88db5368885e5bd931

I think it is an implementation detail and don't change any behavior.

It is possible to maintain them in the list, but I have to think how to do it without increasing the size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My change remove static rules that will never match because you have another rule matching before. This way I can trust if it exists in path map, it should be used instead of running through the matching loop.

Copy link
Member

@posva posva Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, these need to be added back, allowing a trailing slash when strict is false is necessary. If you think this is too much, that's fine, it's better to drop these changes on v3

Copy link
Contributor Author

@iurisilvio iurisilvio Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the test to assert that the parent route is not removed from the list when child route is strict. It don't change matching behavior.

/bar was not removed because /bar/ is strict, but /bar-redirect will never be reached, so it was removed.

I'm ok if it is not merged and I'll work on v3 soon to avoid O(n) matches.

@buserbrasil buserbrasil closed this by deleting the head repository Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants