From 74b0dc336650ed53d5b6e2c2406d794dc4abf54d Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Sun, 1 Aug 2021 00:14:31 +0800 Subject: [PATCH 1/2] feat(core): support paths without html extension (close #292) --- .../@vuepress/core/src/app/prepare/preparePagesRoutes.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts b/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts index c8dd2dae78..adf1cc85b1 100644 --- a/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts +++ b/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts @@ -27,10 +27,12 @@ ${app.pages // redirect from decoded path redirectsSet.add(decodeURI(path)) - // redirect from index path if (/\/$/.test(path)) { - const indexPath = path + 'index.html' - redirectsSet.add(indexPath) + // redirect from index path + redirectsSet.add(path + 'index.html') + } else { + // redirect from the path that does not end with `.html` + redirectsSet.add(path.replace(/.html$/, '')) } // redirect from inferred path From bc39ee9a354d91d455817cc7f0555bcc9be03bcd Mon Sep 17 00:00:00 2001 From: meteorlxy Date: Sun, 1 Aug 2021 00:17:22 +0800 Subject: [PATCH 2/2] chore: tweaks --- packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts b/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts index adf1cc85b1..b083eb2648 100644 --- a/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts +++ b/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts @@ -27,7 +27,7 @@ ${app.pages // redirect from decoded path redirectsSet.add(decodeURI(path)) - if (/\/$/.test(path)) { + if (path.endsWith('/')) { // redirect from index path redirectsSet.add(path + 'index.html') } else {