import { remove as removeDiacritics } from 'diacritics' ; const rControl = /[\u0000-\u001f]/g ; const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g ; export const slugify = ( str ) : string => { return ( removeDiacritics ( str ) . replace ( rControl , '' ) . replace ( rSpecial , '-' ) . replace ( /\-{2,}/g , '-' ) . replace ( /^\-+|\-+$/g , '' ) . replace ( /^(\d)/ , '_$1' ) . toLowerCase ( ) ) ; } ;