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 a flag to unescape variable values #662

Closed
wants to merge 3 commits into from
Closed

Add a flag to unescape variable values #662

wants to merge 3 commits into from

Conversation

francescomari
Copy link

Fixes #639

Summary of Changes

  1. Add a new router option configurabile via UnescapeVars.
  2. When UnescapeVars is active, variable values are automatically unescaped when a match is found.
  3. When UnescapeVars is active, variable values are automatically escaped before generating the route's URL.

@francescomari
Copy link
Author

@elithrar I tried to fix #639 with as few changes as possible, but I figured that it would have been difficult to maintain backwards compatibility without adding another option to the Router. If you think this is not the right way to go, please provide guidance on how to proceed (or whether #639 should be fixed at all).

mux.go Show resolved Hide resolved
@francescomari
Copy link
Author

@elithrar I have a question re. the consistency of the API. UseEncodedPath receives no arguments, but UnescapeVars does receive a boolean. Wouldn't look more consistent if UnescapeVars received no arguments, too? If called, it would just activate the flag, like UseEncodedPath does.

@elithrar
Copy link
Contributor

Wouldn't look more consistent if UnescapeVars received no arguments, too? If called, it would just activate the flag, like UseEncodedPath does.

Yes, unlabeled (Go doesn't have labelled args), single Boolean arguments are a bit of an anti-pattern.

@francescomari
Copy link
Author

I've removed the flag. Now UnescapeVars just set the flag as true under the hood.

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.

@stale stale bot added the stale label Apr 17, 2022
@stale stale bot closed this May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Wrong URL matching when url containing encoded slash (%2F)
2 participants