fix(slugify): GitHub compatible heading links, fixed #267

This commit is contained in:
qingwei.li 2017-10-02 13:26:36 +08:00
commit c195d2d1a6

View file

@ -4,8 +4,9 @@ const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g
export function slugify (str) {
if (typeof str !== 'string') return ''
str = /^[\w\s]+$/g.test(str) ? str.toLowerCase() : str
let slug = str
.toLowerCase()
.trim()
.replace(/<[^>\d]+>/g, '')
.replace(re, '')