uritemplates
uritemplates copied to clipboard
hyphen ("-") in named path params is treated invalid
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])+$"
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}