Skip to content

Instantly share code, notes, and snippets.

@martinusso
Created September 25, 2023 19:34
Show Gist options
  • Save martinusso/15dcf69b4884eca4308582e776694c8b to your computer and use it in GitHub Desktop.
Save martinusso/15dcf69b4884eca4308582e776694c8b to your computer and use it in GitHub Desktop.
export const removeAccents = (str): string =>
str.normalize('NFD').replace(/\p{Mn}/gu, '');
export function sanitize(text?: string | undefined): string {
if (!text) return '';
return removeAccents(text.toLocaleLowerCase()).split(' ').join('-');
}
export function parameterize(text?: string | undefined): string {
if (!text) return '';
return sanitize(text.replace(':', '-'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment