vault/ui/app/utils/path-encoding-helpers.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

28 lines
625 B
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
function encodePath(path) {
return path
? path
.split('/')
.map((segment) => encodeURIComponent(segment))
.join('/')
: path;
}
function normalizePath(path) {
// Unlike normalizePath from route-recognizer, this method assumes
// we do not have percent-encoded data octets as defined in
// https://datatracker.ietf.org/doc/html/rfc3986
return path
? path
.split('/')
.map((segment) => decodeURIComponent(segment))
.join('/')
: '';
}
export { normalizePath, encodePath };