MCPcopy Index your code
hub / github.com/php/frankenphp / matchesPath

Method matchesPath

caddy/workerconfig.go:176–201  ·  view source on GitHub ↗
(r *http.Request, documentRoot string)

Source from the content-addressed store, hash-verified

174}
175
176func (wc *workerConfig) matchesPath(r *http.Request, documentRoot string) bool {
177 // try to match against a pattern if one is assigned
178 if len(wc.MatchPath) != 0 {
179 return (caddyhttp.MatchPath)(wc.MatchPath).Match(r)
180 }
181
182 // fast path: compare the request URL path against the pre-computed relative path
183 if wc.matchRelPath != "" {
184 reqPath := r.URL.Path
185 if reqPath == wc.matchRelPath {
186 return true
187 }
188
189 // ensure leading slash for relative paths (see #2166)
190 if reqPath == "" || reqPath[0] != '/' {
191 reqPath = "/" + reqPath
192 }
193
194 return path.Clean(reqPath) == wc.matchRelPath
195 }
196
197 // fallback when documentRoot is dynamic (contains placeholders)
198 fullPath, _ := fastabs.FastAbs(filepath.Join(documentRoot, r.URL.Path))
199
200 return fullPath == wc.absFileName
201}

Callers 1

ServeHTTPMethod · 0.80

Calls 1

FastAbsFunction · 0.92

Tested by

no test coverage detected