Fix license.ts#replaceLicenseDefaults

This commit is contained in:
Mathias Wagner
2024-07-22 14:21:56 +02:00
parent 9e9ce28a8f
commit 88899317bc

View File

@ -29,13 +29,26 @@ export const generateRandom = () => {
} }
export const replaceLicenseDefaults = (defaultKey: string) => { export const replaceLicenseDefaults = (defaultKey: string) => {
return defaultKey.replace(/N/g, () => String(Math.floor(Math.random() * 10))) return defaultKey.split('').map(char => {
.replace(/C/g, () => generateCharacter()) switch (char) {
.replace(/L/g, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)) case 'N':
.replace(/U/g, () => String.fromCharCode(Math.floor(Math.random() * 26) + 65)) return String(Math.floor(Math.random() * 10));
.replace(/S/g, () => generateSpecialCharacter()) case 'C':
.replace(/A/g, () => generateAlphaNumeric()) return generateCharacter();
.replace(/R/g, () => generateRandom()); case 'L':
return String.fromCharCode(Math.floor(Math.random() * 26) + 97);
case 'U':
return String.fromCharCode(Math.floor(Math.random() * 26) + 65);
case 'S':
return generateSpecialCharacter();
case 'A':
return generateAlphaNumeric();
case 'R':
return generateRandom();
default:
return char;
}
}).join('');
} }
export const checkLicenseConfiguration = async (access: IProject, config: ILicense) => { export const checkLicenseConfiguration = async (access: IProject, config: ILicense) => {