This commit is contained in:
chamikaJ
2025-04-17 18:28:54 +05:30
parent f583291d8a
commit 8825b0410a
2837 changed files with 241385 additions and 127578 deletions

View File

@@ -40,22 +40,22 @@ function customKey(initialKey: string | null, existingKeys: string[], len = 3):
}
export function generateProjectKey(projectName: string, existingKeys: string[] = []) {
if (isUnicode(projectName)) return customKey(null, existingKeys);
if (isUnicode(projectName)) return customKey(null, existingKeys).slice(0, 5);
const key = getInitialKey(projectName);
const key = getInitialKey(projectName)?.slice(0, 5);
if (existingKeys.includes(key as string)) {
// try with project name
const name = projectName.toUpperCase().trim();
const chars = [...name.slice(1).replace(/\s/g, "")];
for (const char of chars) {
const k = key + char;
const k = (key + char).slice(0, 5);
if (!existingKeys.includes(k))
return k;
}
return customKey(key as string, existingKeys);
return customKey(key as string, existingKeys).slice(0, 5);
}
return key;
}
}