From 9b4e6669dbf454ea17ee42331487825475130d40 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 7 Oct 2017 10:08:09 +0800 Subject: [PATCH] fix(slugify): GitHub compatible heading links, fixed #272 --- src/core/render/slugify.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/render/slugify.js b/src/core/render/slugify.js index 4b71337d5..046a06c17 100644 --- a/src/core/render/slugify.js +++ b/src/core/render/slugify.js @@ -1,13 +1,16 @@ let cache = {} const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g +function lower (string) { + return string.toLowerCase() +} + export function slugify (str) { if (typeof str !== 'string') return '' - str = /^[\w\s]+$/g.test(str) ? str.toLowerCase() : str - let slug = str .trim() + .replace(/[A-Z]+/g, lower) .replace(/<[^>\d]+>/g, '') .replace(re, '') .replace(/\s/g, '-')