mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
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:
3
changelog/28669.txt
Normal file
3
changelog/28669.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
core: Fixed panic seen when performing help requests without /v1/ in the URL.
|
||||
```
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user