Introduce ctx.PathParamRaw to avoid incorrect unescaping (#26392) (#26405)

Backport #26392 by @wxiaoguang

Fix #26389

And complete an old TODO: `ctx.Params does un-escaping,..., which is
incorrect.`

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
(cherry picked from commit 2d1a7e1cd42b31a62ca627423d088339809238c8)
This commit is contained in:
Giteabot 2023-08-09 15:31:44 +08:00 committed by Earl Warren
parent 119afd3761
commit 8265bece8e
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
5 changed files with 27 additions and 17 deletions

View file

@ -143,6 +143,10 @@ func (b *Base) Params(p string) string {
return s
}
func (b *Base) PathParamRaw(p string) string {
return chi.URLParam(b.Req, strings.TrimPrefix(p, ":"))
}
// ParamsInt64 returns the param on route as int64
func (b *Base) ParamsInt64(p string) int64 {
v, _ := strconv.ParseInt(b.Params(p), 10, 64)