From 60cee7fd2f90dacb9cb3d802bd86b26918b7f67c Mon Sep 17 00:00:00 2001 From: Priere <44214460+shiyouganai@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:37:49 -0500 Subject: [PATCH 1/2] Fix to not add trailing slash to URL with filename --- website/astro.config.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/website/astro.config.mjs b/website/astro.config.mjs index b6617704..6ef307ef 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -33,8 +33,11 @@ function relativeURLFix() { newHref += `/${path}/${url.href}`; } else if (url.href.startsWith('/')) { // any other relative url starting with / - // NOTE: this does strip off serialized queries and fragments - newHref += url.pathname.endsWith('/') ? url.pathname : url.pathname + '/'; + newHref += url.pathname; + if (url.pathname.indexOf('.') == -1) { + // append trailing slash to resource only if there is no file extension + newHref += url.pathname.endsWith('/') ? '' : '/'; + } newHref += url.hash || ''; } else { // leave this URL alone From 78b2b5ccc3380a5176faa8651eb2312157af6f60 Mon Sep 17 00:00:00 2001 From: Priere <44214460+shiyouganai@users.noreply.github.com> Date: Wed, 6 Dec 2023 17:54:29 -0500 Subject: [PATCH 2/2] Don't trim serialized query part of URL --- website/astro.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 6ef307ef..c5ca3317 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -38,6 +38,7 @@ function relativeURLFix() { // append trailing slash to resource only if there is no file extension newHref += url.pathname.endsWith('/') ? '' : '/'; } + newHref += url.search || ''; newHref += url.hash || ''; } else { // leave this URL alone