2019-12-11 17:31:15 +08:00
|
|
|
package route
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
|
2021-04-03 14:59:03 +08:00
|
|
|
"github.com/go-chi/chi/v5"
|
2019-12-11 17:31:15 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// When name is composed of a partial escape string, Golang does not unescape it
|
|
|
|
func getEscapeParam(r *http.Request, paramName string) string {
|
|
|
|
param := chi.URLParam(r, paramName)
|
|
|
|
if newParam, err := url.PathUnescape(param); err == nil {
|
|
|
|
param = newParam
|
|
|
|
}
|
|
|
|
return param
|
|
|
|
}
|