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

Add config option for slashes within route params #2953

Closed
FullStackAlex opened this issue Oct 2, 2019 · 2 comments
Closed

Add config option for slashes within route params #2953

FullStackAlex opened this issue Oct 2, 2019 · 2 comments

Comments

@FullStackAlex
Copy link

What problem does this feature solve?

It would allow within the Vue app a controlled routing of flexible / unpredictable, nested hierarchical categories e.g.: "post-type/post-category/sub-category/sub-sub-category/post-name"
Currently this is not possible due to encoding of the params by encodeURIComponent within vue-router, which leads to slashes being encoded as %2F.

What does the proposed API look like?

Kind of:

<router-link :to={name: "CustomPost", params:{category: "post-category/sub-category/sub-sub-category", post:"post-name"}, encodeURIcomponent: false}></router-link>
@posva
Copy link
Member

posva commented Oct 3, 2019

Slashes are separators in routes, so they have to be encoded when used in params. You can directly provide a path or a string version to control the escaping but note you will also have to provide a custom regexp to the param: path: '/:p(.*)'.

I think the best way for your case would be to use a repeated param: '/:p+' and then provide an array of params: { params: { p: ['one', 'two'] }}

@posva posva closed this as completed Oct 3, 2019
@FullStackAlex
Copy link
Author

Hmm, ok. Thank you for the repeated param idea. I'll try it out.

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