manifold/web/lib/util/slugify.ts
Austin Chen d4bb419478 Prettier everything
(Hopefully for the last time)
2021-12-13 23:30:09 -08:00

11 lines
420 B
TypeScript

export const slugify = (text: any, separator = '-'): string => {
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)
}