mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
* 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>
13 lines
461 B
JavaScript
13 lines
461 B
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
// will trim a given set of endings from the end of a string
|
|
// if isExtension is true, the first char of that string will be escaped
|
|
// in the regex
|
|
export default function (str, endings = [], isExtension = true) {
|
|
const prefix = isExtension ? '\\' : '';
|
|
const trimRegex = new RegExp(endings.map((ext) => `${prefix}${ext}$`).join('|'));
|
|
return str.replace(trimRegex, '');
|
|
}
|