fix: check base before redirecting to .html

closse #852
pull/853/head
JounQin 3 years ago
parent 00fe8092d9
commit f522cdaec4

@ -42,7 +42,11 @@ export function createRouter(
function go(href: string = inBrowser ? location.href : '/') { function go(href: string = inBrowser ? location.href : '/') {
// ensure correct deep link so page refresh lands on correct files. // ensure correct deep link so page refresh lands on correct files.
const url = new URL(href, fakeHost) const url = new URL(href, fakeHost)
if (!url.pathname.endsWith('/') && !url.pathname.endsWith('.html')) { if (
!url.pathname.endsWith('/') &&
!url.pathname.endsWith('.html') &&
url.pathname + '/' !== siteDataRef.value.base
) {
url.pathname += '.html' url.pathname += '.html'
href = url.pathname + url.search + url.hash href = url.pathname + url.search + url.hash
} }

Loading…
Cancel
Save