From a745d1bab93546073124378888312d3bafb57db2 Mon Sep 17 00:00:00 2001 From: Georges Gomes Date: Mon, 4 Jul 2022 14:37:56 +0200 Subject: [PATCH] nicer without trailing slash --- src/client/app/router.ts | 2 +- src/client/theme-default/support/utils.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 9a3337e8..f6168978 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -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) { diff --git a/src/client/theme-default/support/utils.ts b/src/client/theme-default/support/utils.ts index 9acbce92..07ba1ebe 100644 --- a/src/client/theme-default/support/utils.ts +++ b/src/client/theme-default/support/utils.ts @@ -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) }