Skip to content

Path as regex instead of strings #1177

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

Closed
Dadibom opened this issue Feb 17, 2017 · 8 comments
Closed

Path as regex instead of strings #1177

Dadibom opened this issue Feb 17, 2017 · 8 comments

Comments

@Dadibom
Copy link

Dadibom commented Feb 17, 2017

Vue.js / vue-router versions

2.1.10 / 2.2.1

Trying to add a route with a negative lookahead regex, path: '/(?!PathThatShouldNotBeMatched)', however the exclamation mark is automagically escaped before passed to the regex tester.

@posva
Copy link
Member

posva commented Feb 18, 2017

Paths are not regexes, they're transformed to regexes.
We could maybe allow the user to use his own regexes.
Why would you need to use a custom regex in a path?

@posva posva changed the title Negative lookahead regexes in paths are escaped Path as regex instead of strings Feb 18, 2017
@Dadibom
Copy link
Author

Dadibom commented Feb 18, 2017

I don't really need to use custom regex, though it would make the path system more flexible. I just want a way to match everything BUT something specific. This is an alternate solution to my problem caused by #1176 , meaning that my wildcard route could have exceptions for the routes i add dynamically.

@Dadibom
Copy link
Author

Dadibom commented Feb 18, 2017

Or maybe, replace the wildcard route with something that always matches anything unmatched, that is always checked last

@Dadibom
Copy link
Author

Dadibom commented Feb 18, 2017

Like routes: [{...}], notFound: {...}

@fnlctrl
Copy link
Member

fnlctrl commented Feb 18, 2017

Since the current route matching is completely done by path-to-regexp, it's very unlikely to add such feature in vue-router. @Dadibom can you check out path-to-regexp's docs and see if it's features can work for your use case?

@posva
Copy link
Member

posva commented Feb 18, 2017

I should have referenced this when I saw it 😄 pillarjs/path-to-regexp#99

Anyway, I don't think we need to add anything. We should look at #1176 instead

@LinusBorg
Copy link
Member

So can we agree to close this because we are committed to path2regexp?

@posva @fnlctrl @Dadibom

@posva
Copy link
Member

posva commented Feb 23, 2017

Yes, we should close this because the real issue is #1176
Thanks for the reminder 🙂

@posva posva closed this as completed Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants