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

Optional pattern array structure #3

Closed
LasseRosenow opened this issue Feb 16, 2019 · 3 comments
Closed

Optional pattern array structure #3

LasseRosenow opened this issue Feb 16, 2019 · 3 comments

Comments

@LasseRosenow
Copy link
Contributor

I think it would be great, if we could specify multiple patterns for the same route name by using a optional array structure for the pattern property:

router([{
    name: 'home',
    pattern: ['', 'home']
}, {
    name: 'news',
    pattern: 'news'
}, {
    name: 'notfound',
    pattern: '*'
}], (route, params, query) => {
    this.route = route
})
@hamedasemi
Copy link
Owner

The idea is not bad but this can be a bit confusing

['home', 'dashboard'] == home || dashboard 
['home', 'dashboard'] == home/dashboard 

You can also alternatively do this:

router([{
    name: 'home',
    pattern: ''
}, {
    name: 'home',
    pattern: 'home'
}, {
    name: 'news',
    pattern: 'news'
}, {
    name: 'notfound',
    pattern: '*'
}], (route, params, query) => {
    this.route = route
})

@LasseRosenow
Copy link
Contributor Author

Well I myself wouldn't consider this as confusing, but it's your project after all. So you decide, what is best :)
I myself can life with your workaround which is what I'm doing right now anyways :D

@hamedasemi
Copy link
Owner

I will consider this in the next version design :)

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

No branches or pull requests

2 participants