github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/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  }