From b8b9dbc87210a4dce12a3ffed13cb589b3c22a5d Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 10 Jan 2017 14:39:40 +0800 Subject: [PATCH] Fixed number at the beginning of the slug, fixed #51 --- CHANGELOG.md | 4 ++++ src/util.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1082f9c..268b9c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.5.2 +### Bug fixes +- Fixed number at the beginning of the slug + ## 1.5.1 ### Bug fixes - Remove HTML tag when handling slug diff --git a/src/util.js b/src/util.js index fd618aa..e4b67f9 100644 --- a/src/util.js +++ b/src/util.js @@ -120,6 +120,8 @@ export function slugify (string) { .replace(/<[^>\d]+>/g, '') .replace(re, '') .replace(/\s/g, replacement) + .replace(/-+/g, replacement) + .replace(/^(\d)/, '_$1') let occurrences = slugify.occurrences[slug] if (slugify.occurrences.hasOwnProperty(slug)) {