MCPcopy
hub / github.com/cortesi/devd / notFoundSearchPaths

Function notFoundSearchPaths

fileserver/fileserver.go:268–283  ·  view source on GitHub ↗

Given a path and a "not found" over-ride specification, return an array of over-ride paths that should be considered for serving, in priority order. We assume that path is a sub-path above a certain root, and we never return paths that would fall outside this. We also sanity check file extensions t

(pth string, spec string)

Source from the content-addressed store, hash-verified

266// type matches what we serve. This prevents an over-ride for *.html files from
267// serving up data when, say, a missing .png is requested.
268func notFoundSearchPaths(pth string, spec string) []string {
269 var ret []string
270 if strings.HasPrefix(spec, "/") {
271 ret = []string{path.Clean(spec)}
272 } else {
273 for {
274 pth = path.Dir(pth)
275 if pth == "/" {
276 ret = append(ret, path.Join(pth, spec))
277 break
278 }
279 ret = append(ret, path.Join(pth, spec))
280 }
281 }
282 return ret
283}
284
285// Get the media type for an extension, via a MIME lookup, defaulting to
286// "text/html".

Callers 2

TestNotFoundSearchPathsFunction · 0.85
notFoundMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestNotFoundSearchPathsFunction · 0.68