mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-12-12 22:51:14 +00:00
24 lines
524 B
JavaScript
24 lines
524 B
JavaScript
/**
|
|
* Copyright IBM Corp. 2019, 2025
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
/**
|
|
* Replaces any dot chars to __ and removes non-ascii charts
|
|
* @param {string} dataKey
|
|
* @param {boolean=} isEnvVar
|
|
*/
|
|
function normalizeOutputKey(dataKey, upperCase = false) {
|
|
let outputKey = dataKey
|
|
.replaceAll(".", "__")
|
|
.replace(new RegExp("-", "g"), "")
|
|
.replace(/[^\p{L}\p{N}_-]/gu, "");
|
|
if (upperCase) {
|
|
outputKey = outputKey.toUpperCase();
|
|
}
|
|
return outputKey;
|
|
}
|
|
|
|
module.exports = {
|
|
normalizeOutputKey
|
|
};
|