github.com/kelleygo/clashcore@v1.0.2/hub/route/common.go (about)

     1  package route
     2  
     3  import (
     4  	"net/http"
     5  	"net/url"
     6  
     7  	"github.com/go-chi/chi/v5"
     8  )
     9  
    10  // When name is composed of a partial escape string, Golang does not unescape it
    11  func getEscapeParam(r *http.Request, paramName string) string {
    12  	param := chi.URLParam(r, paramName)
    13  	if newParam, err := url.PathUnescape(param); err == nil {
    14  		param = newParam
    15  	}
    16  	return param
    17  }