2021-12-14 01:07:28 +00:00
|
|
|
export const slugify = (text: any, separator = '-'): string => {
|
2021-12-14 07:30:09 +00:00
|
|
|
return text
|
|
|
|
.toString()
|
|
|
|
.normalize('NFD') // split an accented letter in the base letter and the acent
|
|
|
|
.replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
|
|
|
|
.toLowerCase()
|
|
|
|
.trim()
|
|
|
|
.replace(/[^a-z0-9 ]/g, '') // remove all chars not letters, numbers and spaces (to be replaced)
|
|
|
|
.replace(/\s+/g, separator)
|
|
|
|
}
|