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') {
return null;
}
return url
.replace(/\/index.html$/, '.md')
.replace(/\.html$/, '.md')
.replace(new RegExp('/', 'g'), '-');
return url.replace(/(\/index)?\.html$/, '.md').replace(/\//g, '-');
}
function fileToUrl(file) {