github.com/sagernet/sing-box@v1.9.0-rc.20/experimental/clashapi/common.go (about)

     1  package clashapi
     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  }