From 63d0acc5f2dcedbdba20ec42e1a848f9d3322451 Mon Sep 17 00:00:00 2001 From: Georges Gomes Date: Tue, 5 Jul 2022 09:57:28 +0200 Subject: [PATCH] Fixing trailing slash setup --- src/client/app/router.ts | 5 ++++- src/client/app/utils.ts | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 88d5f722..4980dafb 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -109,7 +109,10 @@ export function createRouter( } } } catch (err: any) { - if (!err.message.match(/fetch/) && !/^[\\/]404(\.html)?$/.test(href)) { + if ( + !err.message.match(/fetch/) && + !/^[\\/]404[\\/]?(\.html)?$/.test(href) + ) { console.error(err) } diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 91b8da5b..7708cf82 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -22,8 +22,13 @@ export function withBase(path: string) { export function pathToFile(path: string): string { let pagePath = path.replace(/\.html$/, '') pagePath = decodeURIComponent(pagePath) - if (pagePath.endsWith('/')) { + if (siteDataRef.value.cleanUrls === 'off' && pagePath.endsWith('/')) { pagePath += 'index' + } else if ( + siteDataRef.value.cleanUrls === 'with-trailing-slash' && + pagePath.endsWith('/') + ) { + pagePath = pagePath.slice(0, -1) } if (import.meta.env.DEV) {