refactor: simplify blog url replacement regex (#1491)

This commit is contained in:
Hongarc 2019-05-19 15:20:49 +07:00 committed by Endi
parent cbd2a589e3
commit 9a18b7430a

View file

@ -19,10 +19,7 @@ function urlToSource(url) {
if (!url || typeof url !== 'string') { if (!url || typeof url !== 'string') {
return null; return null;
} }
return url return url.replace(/(\/index)?\.html$/, '.md').replace(/\//g, '-');
.replace(/\/index.html$/, '.md')
.replace(/\.html$/, '.md')
.replace(new RegExp('/', 'g'), '-');
} }
function fileToUrl(file) { function fileToUrl(file) {