summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Drew Powers <1369770+drwpow@users.noreply.github.com> 2021-11-19 12:57:24 -0700
committerGravatar GitHub <noreply@github.com> 2021-11-19 12:57:24 -0700
commitf7b23d5cf19e85181176856b46c88ae7b3d78462 (patch)
treec0381132c7c6e98a136e85506a5b0e4c881e1de5
parent16926755758790e0396a2301578de72fafefa1ea (diff)
downloadastro-f7b23d5cf19e85181176856b46c88ae7b3d78462.tar.gz
astro-f7b23d5cf19e85181176856b46c88ae7b3d78462.tar.zst
astro-f7b23d5cf19e85181176856b46c88ae7b3d78462.zip
Allow search params (#1927)
Fixes #1795
-rw-r--r--packages/astro/src/core/dev/index.ts4
-rw-r--r--packages/astro/test/dev-routing.test.js5
2 files changed, 7 insertions, 2 deletions
diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts
index 3aad5e444..924cd87ec 100644
--- a/packages/astro/src/core/dev/index.ts
+++ b/packages/astro/src/core/dev/index.ts
@@ -110,7 +110,7 @@ export class AstroDevServer {
}
const route = this.mostRecentRoute;
- const pathname = route?.pathname ?? '/';
+ const [pathname, search = undefined] = (route?.pathname ?? '/').split('?');
if (!route) {
viteServer.ws.send({
@@ -274,7 +274,7 @@ export class AstroDevServer {
private async handleRequest(req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) {
if (!this.viteServer) throw new Error(`AstroDevServer.start() not called`);
- let pathname = req.url || '/'; // original request
+ let [pathname, search = undefined] = (req.url || '/').split('?'); // original request
const reqStart = performance.now();
let filePath: URL | undefined;
try {
diff --git a/packages/astro/test/dev-routing.test.js b/packages/astro/test/dev-routing.test.js
index 98ea79df3..129942c83 100644
--- a/packages/astro/test/dev-routing.test.js
+++ b/packages/astro/test/dev-routing.test.js
@@ -23,6 +23,11 @@ describe('Development Routing', () => {
expect(response.status).to.equal(200);
});
+ it('200 when adding search params', async () => {
+ const response = await fixture.fetch('/?foo=bar');
+ expect(response.status).to.equal(200);
+ });
+
it('200 when loading non-root page', async () => {
const response = await fixture.fetch('/another');
expect(response.status).to.equal(200);