mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-07 15:16:56 +00:00
19 lines
446 B
JavaScript
19 lines
446 B
JavaScript
/**
|
|
* Replaces any dot chars to __ and removes non-ascii charts
|
|
* @param {string} dataKey
|
|
* @param {boolean=} isEnvVar
|
|
*/
|
|
function normalizeOutputKey(dataKey, upperCase = false) {
|
|
let outputKey = dataKey
|
|
.replace(".", "__")
|
|
.replace(new RegExp("-", "g"), "")
|
|
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
|
if (upperCase) {
|
|
outputKey = outputKey.toUpperCase();
|
|
}
|
|
return outputKey;
|
|
}
|
|
|
|
module.exports = {
|
|
normalizeOutputKey
|
|
};
|