MCPcopy
hub / github.com/caddyserver/caddy / MatchWithError

Method MatchWithError

modules/caddyhttp/matchers.go:714–723  ·  modules/caddyhttp/matchers.go::MatchPathRE.MatchWithError

MatchWithError returns true if r matches m.

(r *http.Request)

Source from the content-addressed store, hash-verified

712
713// MatchWithError returns true if r matches m.
714func (m MatchPathRE) MatchWithError(r *http.Request) (bool, error) {
715 repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)
716
717 // Clean the path, merges doubled slashes, etc.
718 // This ensures maliciously crafted requests can't bypass
719 // the path matcher. See #4407
720 cleanedPath := cleanPath(r.URL.Path)
721
722 return m.MatchRegexp.Match(cleanedPath, repl), nil
723}
724
725// CELLibrary produces options that expose this matcher for use in CEL
726// expression matchers.

Callers 1

MatchMethod · 0.95

Calls 3

cleanPathFunction · 0.85
MatchMethod · 0.65
ValueMethod · 0.45

Tested by

no test coverage detected