MCPcopy Create free account
hub / github.com/cli/cli / JoinPathWithHostPrefix

Function JoinPathWithHostPrefix

internal/safeurl/safeurl.go:64–69  ·  view source on GitHub ↗

JoinPathWithHostPrefix returns a SafeURL for the given host prefix and the path made up of the given components. It returns an error if any component is exactly "..", which would traverse the URL path and change which resource it addresses.

(hostPrefix string, components ...string)

Source from the content-addressed store, hash-verified

62// made up of the given components. It returns an error if any component is exactly
63// "..", which would traverse the URL path and change which resource it addresses.
64func JoinPathWithHostPrefix(hostPrefix string, components ...string) (*MutableSafeURL, error) {
65 if err := checkTraversal(components); err != nil {
66 return nil, err
67 }
68 return &MutableSafeURL{prefix: hostPrefix, components: components}, nil
69}
70
71// checkTraversal returns an error if any component is exactly "..". Such a component
72// survives percent-encoding as a real path segment and would traverse the URL path.

Callers 15

searchMethod · 0.92
deleteTagFunction · 0.92
FetchRefSHAFunction · 0.92
FetchReleaseFunction · 0.92
FetchLatestReleaseFunction · 0.92
fetchDraftReleaseFunction · 0.92
getTagsFunction · 0.92
generateReleaseNotesFunction · 0.92
publishedReleaseExistsFunction · 0.92
createReleaseFunction · 0.92
editReleaseFunction · 0.92
GetCurrentLoginFunction · 0.92

Calls 1

checkTraversalFunction · 0.85

Tested by 2

TestMutableSafeURLStringFunction · 0.74