From fad027f9a282a4ab471833178536392a49c1af2c Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Fri, 10 Nov 2023 12:57:51 +0530 Subject: [PATCH 1/4] Update vite-plugin-astro-preview.ts --- packages/astro/src/core/preview/vite-plugin-astro-preview.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts index 9faabe29b21e..acc2912baf85 100644 --- a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts +++ b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts @@ -24,7 +24,8 @@ export function vitePluginAstroPreview(settings: AstroSettings): Plugin { return; } - const pathname = stripBase(req.url!, base); + let strippedPathname = stripBase(req.url!, base); + const pathname = new URL(strippedPathname, 'https://test.com').pathname const isRoot = pathname === '/'; // Validate trailingSlash From e841956324fdcc525b8006621d279c67ac26a2f9 Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Fri, 10 Nov 2023 12:59:51 +0530 Subject: [PATCH 2/4] Create tidy-peas-accept.md --- .changeset/tidy-peas-accept.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tidy-peas-accept.md diff --git a/.changeset/tidy-peas-accept.md b/.changeset/tidy-peas-accept.md new file mode 100644 index 000000000000..b99e328dfc0b --- /dev/null +++ b/.changeset/tidy-peas-accept.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +fix preview server pathname parse From f640c31fcf2c5ee001e37de7b02c0ce27e122999 Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Sat, 11 Nov 2023 10:09:45 +0530 Subject: [PATCH 3/4] const instead of let --- packages/astro/src/core/preview/vite-plugin-astro-preview.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts index acc2912baf85..b07b88b7ad99 100644 --- a/packages/astro/src/core/preview/vite-plugin-astro-preview.ts +++ b/packages/astro/src/core/preview/vite-plugin-astro-preview.ts @@ -24,8 +24,8 @@ export function vitePluginAstroPreview(settings: AstroSettings): Plugin { return; } - let strippedPathname = stripBase(req.url!, base); - const pathname = new URL(strippedPathname, 'https://test.com').pathname + const strippedPathname = stripBase(req.url!, base); + const pathname = new URL(strippedPathname, 'https://a.b').pathname const isRoot = pathname === '/'; // Validate trailingSlash From f2b3a4a7a98d2c8e19efe17ee87a8d8a3636331e Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 14 Nov 2023 17:38:46 +0800 Subject: [PATCH 4/4] Update .changeset/tidy-peas-accept.md --- .changeset/tidy-peas-accept.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tidy-peas-accept.md b/.changeset/tidy-peas-accept.md index b99e328dfc0b..fa580f073449 100644 --- a/.changeset/tidy-peas-accept.md +++ b/.changeset/tidy-peas-accept.md @@ -2,4 +2,4 @@ 'astro': patch --- -fix preview server pathname parse +Fixes preview server `trailingSlash` handling for request URLs with query strings