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

Function singleJoiningSlash

reverseproxy/reverseproxy.go:51–65  ·  view source on GitHub ↗
(a, b string)

Source from the content-addressed store, hash-verified

49}
50
51func singleJoiningSlash(a, b string) string {
52 if b == "" {
53 return a
54 }
55
56 aslash := strings.HasSuffix(a, "/")
57 bslash := strings.HasPrefix(b, "/")
58 switch {
59 case aslash && bslash:
60 return a + b[1:]
61 case !aslash && !bslash:
62 return a + "/" + b
63 }
64 return a + b
65}
66
67// NewSingleHostReverseProxy returns a new ReverseProxy that rewrites
68// URLs to the scheme, host, and base path provided in target. If the

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected