MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / realURLPath

Function realURLPath

pkg/fetch/fetch.go:43–61  ·  view source on GitHub ↗

realURLPath replaces path root of p by r if r != "" and returns p otherwise. realURLPath assumes URL paths and assumes that both paths are cleaned.

(rURL *url.URL, p string)

Source from the content-addressed store, hash-verified

41// realURLPath replaces path root of p by r if r != "" and returns p otherwise.
42// realURLPath assumes URL paths and assumes that both paths are cleaned.
43func realURLPath(rURL *url.URL, p string) (string, error) {
44 pURL, err := url.Parse(p)
45 if err != nil {
46 return "", err
47 }
48 if rURL == nil {
49 if !pURL.IsAbs() {
50 return "", errSchemeNotSpecified.New()
51 }
52 return p, nil
53 }
54 if pURL.IsAbs() {
55 return "", errSchemeSpecified.New()
56 }
57 if !rURL.IsAbs() {
58 return "", errSchemeNotSpecified.New()
59 }
60 return fmt.Sprintf("%s/%s", rURL, pURL.EscapedPath()), nil
61}
62
63// realOSPath replaces path root of p by r if r != "" and returns p otherwise.
64// realOSPath assumes operating system paths and that both paths are cleaned.

Callers 1

FileMethod · 0.85

Calls 2

ParseMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected