diff options
author | 2023-11-14 15:09:37 +0530 | |
---|---|---|
committer | 2023-11-14 17:39:37 +0800 | |
commit | 84312f24f8af2098b0831cf2361ea3d37761d3d3 (patch) | |
tree | f1ba07914ce5a1fa7d7886ce98f2ab4801ae9889 | |
parent | b895113a0ae347ecd81bd8866ae2d816ea20836b (diff) | |
download | astro-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.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/preview/vite-plugin-astro-preview.ts | 3 |
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 |