Add util for trim v1

This commit is contained in:
Cohee
2023-12-21 22:40:08 +02:00
parent 09fd772a20
commit b782a8cc03
2 changed files with 15 additions and 10 deletions

View File

@ -458,6 +458,15 @@ function excludeKeysByYaml(obj, yamlString) {
}
}
/**
* Removes trailing slash and /v1 from a string.
* @param {string} str Input string
* @returns {string} Trimmed string
*/
function trimV1(str) {
return String(str ?? '').replace(/\/$/, '').replace(/\/v1$/, '');
}
module.exports = {
getConfig,
getConfigValue,
@ -481,4 +490,5 @@ module.exports = {
getHexString,
mergeObjectWithYaml,
excludeKeysByYaml,
trimV1,
};