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

Function joinPathWithHostPrefix

internal/safeurl/safeurl.go:152–164  ·  view source on GitHub ↗

joinPathWithHostPrefix builds a full REST API URL by prepending hostPrefix to the path produced by JoinPath. A single slash is ensured at the join between hostPrefix and the path so they separate cleanly without doubling up. When hostPrefix is empty, the JoinPath result is returned intact, and when

(hostPrefix string, components ...string)

Source from the content-addressed store, hash-verified

150// when the joined path is empty, hostPrefix is returned intact. hostPrefix is used verbatim while each
151// component is percent-encoded.
152func joinPathWithHostPrefix(hostPrefix string, components ...string) string {
153 path := joinPath(components...)
154 if hostPrefix == "" {
155 return path
156 }
157 if path == "" {
158 return hostPrefix
159 }
160 if !strings.HasSuffix(hostPrefix, "/") {
161 return hostPrefix + "/" + path
162 }
163 return hostPrefix + path
164}

Callers 1

StringMethod · 0.85

Calls 1

joinPathFunction · 0.85

Tested by

no test coverage detected