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

Double encoding or no encoding #404

Open
ulfryk opened this issue Mar 4, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@ulfryk
Copy link

commented Mar 4, 2019

If I pass to router.navigate(…, params) a params object containing url encoded value, it's encoded once again, else it's not encoded at all.

I would like to encode value once, but it seems to be impossible now.

Is there any way to force encoding once, or to somehow trigger encoding ?

If there is none I'd be happy to introduce PR with update :)

EDIT: Looks like it's caused by path parser, it happens here:
https://github.com/troch/path-parser/blob/master/modules/Path.ts#L190

I think thaht to fix this an option is needed in both path-parser and router5 to enforce encoding (with encodeURLComponent) or not encoding url param..

@davidgomes

This comment has been minimized.

Copy link

commented Mar 4, 2019

This is happening to us as well.

@ulfryk

This comment has been minimized.

Copy link
Author

commented Mar 5, 2019

There is a workaround. But it's really ugly and not too safe I'd say:

const original = encodeURI
window.encodeURI = encodeURIComponent
router.navigate(routeName, routeParams)
window.encodeURI = original

🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.