Skip to content

Commit 1d41365

Browse files
authored
feat(core): support paths without html extension (close #292) (#324)
1 parent 3ca13b5 commit 1d41365

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ ${app.pages
2727
// redirect from decoded path
2828
redirectsSet.add(decodeURI(path))
2929
30-
// redirect from index path
31-
if (/\/$/.test(path)) {
32-
const indexPath = path + 'index.html'
33-
redirectsSet.add(indexPath)
30+
if (path.endsWith('/')) {
31+
// redirect from index path
32+
redirectsSet.add(path + 'index.html')
33+
} else {
34+
// redirect from the path that does not end with `.html`
35+
redirectsSet.add(path.replace(/.html$/, ''))
3436
}
3537
3638
// redirect from inferred path

0 commit comments

Comments
 (0)