From 20399c496e2d199b6dbaefa1b406f1bbd0921ecc Mon Sep 17 00:00:00 2001 From: Ross Zurowski Date: Mon, 18 Nov 2024 11:07:22 -0500 Subject: [PATCH] fix: ensure pathPrefix works with trailingSlash option This commit fixes an issue where the `pathPrefix` option was ignored when the trailing slash option was set to "never." The cause was that adding the prefix seemed to be left out of a few code paths. --- packages/gatsby-link/src/rewrite-link-path.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-link/src/rewrite-link-path.js b/packages/gatsby-link/src/rewrite-link-path.js index e1b2b496716c7..387deb3c50f60 100644 --- a/packages/gatsby-link/src/rewrite-link-path.js +++ b/packages/gatsby-link/src/rewrite-link-path.js @@ -18,13 +18,14 @@ function applyTrailingSlashOptionOnPathnameOnly(path, option) { } function absolutify(path, current) { + const prefixed = withPrefix(path) // If it's already absolute, return as-is if (isAbsolutePath(path)) { - return path + return prefixed } const option = getGlobalTrailingSlash() - const absolutePath = resolve(path, current) + const absolutePath = resolve(prefixed, current) if (option === `always` || option === `never`) { return applyTrailingSlashOptionOnPathnameOnly(absolutePath, option)