Created
September 25, 2023 19:34
-
-
Save martinusso/15dcf69b4884eca4308582e776694c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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