Skip to content

Commit c94bebf

Browse files
committed
chore: tweaks
1 parent d43d3b6 commit c94bebf

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

packages/@vuepress/core/lib/app/redirect.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// - `/foo.html` means your source file is `/foo.md`
55
//
66
// The original design of VuePress relied on above two styles
7-
// of routing, especially the routing calculations involved in
7+
// of routing, especially the calculation involved of routes at
88
// default theme. so we can't easily modify `/foo.html` directly
99
// to `/foo` (i.e. remove html suffix)
1010
//
@@ -17,15 +17,14 @@
1717
//
1818
// For unknown request `/foo/`
1919
// - redirect to `/foo.html` if it exists
20+
//
21+
// If all the above redirect rules don't exist, you'll get a 404
2022

2123
export default function handleRedirect (router) {
2224
router.beforeEach((to, from, next) => {
2325
if (isRouteExists(router, to.path)) {
2426
next()
2527
} else {
26-
// For unknown request `/foo`
27-
// redirect to /foo/ if exists
28-
// redirect to /foo.html if exists
2928
if (!/(\/|\.html)$/.test(to.path)) {
3029
const endingSlashUrl = to.path + '/'
3130
const endingHtmlUrl = to.path + '.html'
@@ -36,8 +35,6 @@ export default function handleRedirect (router) {
3635
} else {
3736
next()
3837
}
39-
// For unknown request `/foo/`
40-
// redirect to /foo.html if exists
4138
} else if (/\/$/.test(to.path)) {
4239
const endingHtmlUrl = to.path.replace(/\/$/, '') + '.html'
4340
if (isRouteExists(router, endingHtmlUrl)) {

0 commit comments

Comments
 (0)