nicer without trailing slash

pull/869/head
Georges Gomes 3 years ago
parent dafc6c3a31
commit a745d1bab9

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

@ -79,7 +79,10 @@ export function normalizeLink(url: string, cleanUrls: boolean = false): string {
const normalizedPath =
pathname.endsWith('/') || pathname.endsWith('.html')
? url
: `${pathname.replace(/(\.md)?$/, cleanUrls ? '/' : '.html')}${search}${hash}`
: `${pathname.replace(
/(\.md)?$/,
cleanUrls ? '' : '.html'
)}${search}${hash}`
return withBase(normalizedPath)
}

Loading…
Cancel
Save