Fixing trailing slash setup

pull/869/head
Georges Gomes 3 years ago
parent dc49b6fcf1
commit 63d0acc5f2

@ -109,7 +109,10 @@ export function createRouter(
} }
} }
} catch (err: any) { } catch (err: any) {
if (!err.message.match(/fetch/) && !/^[\\/]404(\.html)?$/.test(href)) { if (
!err.message.match(/fetch/) &&
!/^[\\/]404[\\/]?(\.html)?$/.test(href)
) {
console.error(err) console.error(err)
} }

@ -22,8 +22,13 @@ export function withBase(path: string) {
export function pathToFile(path: string): string { export function pathToFile(path: string): string {
let pagePath = path.replace(/\.html$/, '') let pagePath = path.replace(/\.html$/, '')
pagePath = decodeURIComponent(pagePath) pagePath = decodeURIComponent(pagePath)
if (pagePath.endsWith('/')) { if (siteDataRef.value.cleanUrls === 'off' && pagePath.endsWith('/')) {
pagePath += 'index' pagePath += 'index'
} else if (
siteDataRef.value.cleanUrls === 'with-trailing-slash' &&
pagePath.endsWith('/')
) {
pagePath = pagePath.slice(0, -1)
} }
if (import.meta.env.DEV) { if (import.meta.env.DEV) {

Loading…
Cancel
Save