upgrade fast-xml-parser (prepare to replace)

This commit is contained in:
dswbx
2025-03-11 09:27:40 +01:00
parent 722d0bd29e
commit 37df32b51b
5 changed files with 80 additions and 7 deletions

View File

@@ -118,3 +118,17 @@ export function patternMatch(target: string, pattern: RegExp | string): boolean
}
return false;
}
export function slugify(str: string): string {
return (
String(str)
.normalize("NFKD") // split accented characters into their base characters and diacritical marks
// biome-ignore lint/suspicious/noMisleadingCharacterClass: <explanation>
.replace(/[\u0300-\u036f]/g, "") // remove all the accents, which happen to be all in the \u03xx UNICODE block.
.trim() // trim leading or trailing whitespace
.toLowerCase() // convert to lowercase
.replace(/[^a-z0-9 -]/g, "") // remove non-alphanumeric characters
.replace(/\s+/g, "-") // replace spaces with hyphens
.replace(/-+/g, "-") // remove consecutive hyphens
);
}