From dcb0aaea99efbd68175f1d1aeb5076b6dde9801e Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Sun, 19 Apr 2020 22:12:55 +0800 Subject: [PATCH] fix: Inconsistent search and body rendering * fix * Update search.js * Update search.js * Update search.js * Update search.js * Update search.js --- src/plugins/search/search.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 29d74b79e..b1f5f0255 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -25,10 +25,9 @@ function escapeHtml(string) { '>': '>', '"': '"', "'": ''', - '/': '/', }; - return String(string).replace(/[&<>"'/]/g, s => entityMap[s]); + return String(string).replace(/[&<>"']/g, s => entityMap[s]); } function getAllPaths(router) { @@ -66,7 +65,7 @@ export function genIndex(path, content = '', router, depth) { tokens.forEach(token => { if (token.type === 'heading' && token.depth <= depth) { - slug = router.toURL(path, { id: slugify(token.text) }); + slug = router.toURL(path, { id: slugify(escapeHtml(token.text)) }); index[slug] = { slug, title: token.text, body: '' }; } else { if (!slug) {