fix: improve international character handling in prompt commands

This commit is contained in:
David Holmlund
2025-04-17 14:56:57 +02:00
parent 07d8460126
commit 9f8b94e45f
2 changed files with 26 additions and 3 deletions

View File

@@ -1298,3 +1298,17 @@ export const convertOpenApiToToolPayload = (openApiSpec) => {
return toolPayload;
};
export const slugify = (str: string): string => {
return str
// 1. Normalize: separate accented letters into base + combining marks
.normalize("NFD")
// 2. Remove all combining marks (the accents)
.replace(/[\u0300-\u036f]/g, "")
// 3. Replace any sequence of whitespace with a single hyphen
.replace(/\s+/g, "-")
// 4. Remove all characters except alphanumeric characters and hyphens
.replace(/[^a-zA-Z0-9-]/g, "")
// 5. Convert to lowercase
.toLowerCase();
};