only strip v1 prefix from path if present (#28669)

* only strip v1 prefix from path if present

* add changelog entry

* adjust changelog
This commit is contained in:
Chris Capurso
2024-10-10 12:25:14 -04:00
committed by GitHub
parent 6bd2cc03e6
commit 458de6d118
2 changed files with 11 additions and 2 deletions

3
changelog/28669.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
core: Fixed panic seen when performing help requests without /v1/ in the URL.
```

View File

@@ -1417,7 +1417,13 @@ func respondOIDCPermissionDenied(w http.ResponseWriter) {
enc.Encode(oidcResponse)
}
// trimPath removes the /v1/ prefix and the namespace from the path
// trimPath removes the /v1/ prefix (if present) and the namespace from the path
func trimPath(ns *namespace.Namespace, path string) string {
return ns.TrimmedPath(path[len("/v1/"):])
const v1Prefix = "/v1/"
if strings.HasPrefix(path, v1Prefix) {
return ns.TrimmedPath(path[len(v1Prefix):])
}
return ns.TrimmedPath(path)
}