MCPcopy
hub / github.com/harness/harness / pathTerminatedWithMarker

Function pathTerminatedWithMarker

app/api/middleware/encode/encode.go:179–190  ·  view source on GitHub ↗

pathTerminatedWithMarker function encodes a path followed by a custom marker and returns a request with an updated URL.Path. A non-empty prefix can be provided to encode only after the prefix. It allows our Rest API to handle paths of the form "/spaces/space1/space2/+/authToken" Examples: Prefix: "

(r *http.Request, prefix string, marker string, markerReplacement string)

Source from the content-addressed store, hash-verified

177// Prefix: "" Path: "/space1/.gitness.git" => "/space1%2F.gitness"
178// Prefix: "/spaces" Path: "/spaces/space1/space2/+/authToken" => "/spaces/space1%2Fspace2/authToken".
179func pathTerminatedWithMarker(r *http.Request, prefix string, marker string, markerReplacement string) (bool, error) {
180 // r.URL.Path contains URL-decoded URI path. r.URL.RawPath contains raw URI path. But, if the URI don't contain
181 // any character that needs encoding, the r.URL.RawPath is empty (otherwise it would be equal to r.URL.Path).
182
183 // We work with r.URL.RawPath it is exist, or with r.URL.Path if the r.URL.RawPath is empty.
184 urlPath := r.URL.Path
185 if r.URL.RawPath != "" {
186 urlPath = r.URL.RawPath
187 }
188
189 return pathTerminatedWithMarkerAndURL(r, prefix, marker, markerReplacement, urlPath)
190}
191
192func pathTerminatedWithMarkerAndURL(
193 r *http.Request, prefix string, marker string, markerReplacement string, urlPath string,

Callers 2

GitPathBeforeFunction · 0.85
TerminatedPathBeforeFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…