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] 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