summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Rishi Raj Jain <rishi18304@iiitd.ac.in> 2023-11-14 15:09:37 +0530
committerGravatar GitHub <noreply@github.com> 2023-11-14 17:39:37 +0800
commit84312f24f8af2098b0831cf2361ea3d37761d3d3 (patch)
treef1ba07914ce5a1fa7d7886ce98f2ab4801ae9889
parentb895113a0ae347ecd81bd8866ae2d816ea20836b (diff)
downloadastro-84312f24f8af2098b0831cf2361ea3d37761d3d3.tar.gz
astro-84312f24f8af2098b0831cf2361ea3d37761d3d3.tar.zst
astro-84312f24f8af2098b0831cf2361ea3d37761d3d3.zip
fix: Query params trigger the trailingSlash error in preview mode (#9045)
-rw-r--r--.changeset/tidy-peas-accept.md5
-rw-r--r--packages/astro/src/core/preview/vite-plugin-astro-preview.ts3
2 files changed, 7 insertions, 1 deletions
diff --git a/.changeset/tidy-peas-accept.md b/.changeset/tidy-peas-accept.md
new file mode 100644
index 000000000..fa580f073
--- /dev/null
+++ b/.changeset/tidy-peas-accept.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes preview server `trailingSlash` handling for request URLs with query strings
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 9faabe29b..b07b88b7a 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);
+ const strippedPathname = stripBase(req.url!, base);
+ const pathname = new URL(strippedPathname, 'https://a.b').pathname
const isRoot = pathname === '/';
// Validate trailingSlash