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

hyphen ("-") in named path params is treated invalid #11

Open
PankhudiB opened this issue Oct 20, 2020 · 1 comment
Open

hyphen ("-") in named path params is treated invalid #11

PankhudiB opened this issue Oct 20, 2020 · 1 comment

Comments

@PankhudiB
Copy link

PankhudiB commented Oct 20, 2020

uritemplates.Parse() gives error if the path has hyphen in one of the path-param name.

Example :
template, parseErr := uritemplates.Parse("https://api.github.com/repos/{repo-name}")

Gives error :
not a valid name: repo-name

I am not able to comprehend why shouldn't this be allowed ?
the regex used for validation is -----> "^([A-Za-z0-9_\.]|%[0-9A-Fa-f][0-9A-Fa-f])+$"

@jtacoma
Copy link
Owner

jtacoma commented Jan 4, 2021

I’m sorry I didn’t notice this earlier! The dash is not a valid character in variable names:
https://tools.ietf.org/html/rfc6570#section-2.3

You can percent-encode it as %2D instead:

https://api.github.com/repos/{repo%2Dname}

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