package proxy import ( "net/http" "path" "strings" ) // NormalizeRequestURLPath collapses duplicate slashes and dot-segments in req.URL.Path // (path.Clean) and clears RawPath so strip-prefix routing matches the client path even // when the request line contained "//" (e.g. /api//mtg/health). Without this, the path // may not match /api/{alias} and alias routing fails. func NormalizeRequestURLPath(req *http.Request) { if req == nil || req.URL == nil { return } u := req.URL if u.Path == "" { u.Path = "/" u.RawPath = "" return } c := path.Clean(u.Path) if !strings.HasPrefix(c, "/") { c = "/" + c } u.Path = c u.RawPath = "" }