Skip to content

Commit 9b4e666

Browse files
committed
fix(slugify): GitHub compatible heading links, fixed #272
1 parent 2e3fe59 commit 9b4e666

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/render/slugify.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
let cache = {}
22
const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g
33

4+
function lower (string) {
5+
return string.toLowerCase()
6+
}
7+
48
export function slugify (str) {
59
if (typeof str !== 'string') return ''
610

7-
str = /^[\w\s]+$/g.test(str) ? str.toLowerCase() : str
8-
911
let slug = str
1012
.trim()
13+
.replace(/[A-Z]+/g, lower)
1114
.replace(/<[^>\d]+>/g, '')
1215
.replace(re, '')
1316
.replace(/\s/g, '-')

0 commit comments

Comments
 (0)