From 25b98f3f89df0a284c08483f477f07b3aaa60c48 Mon Sep 17 00:00:00 2001 From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np> Date: Mon, 29 Jun 2026 13:24:43 +0545 Subject: [PATCH] Add a failing test for redirect method --- tests/redirect.spec.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/redirect.spec.ts b/tests/redirect.spec.ts index 31ef943..630e488 100644 --- a/tests/redirect.spec.ts +++ b/tests/redirect.spec.ts @@ -359,4 +359,34 @@ test.group('Redirect', () => { const { header } = await supertest(url).get('/').redirects(1) assert.equal(header.location, '/foo') }) + + test('redirect(url, false) must not forward query string even when config.redirect.forwardQueryString is true', async ({ + assert, + }) => { + const { url } = await httpServer.create((req, res) => { + const response = new HttpResponseFactory() + .merge({ + req, + res, + encryption, + router, + config: { + redirect: { + allowedHosts: [], + forwardQueryString: true, // global default is ON + }, + }, + }) + .create() + + // Explicitly opting out of QS forwarding for this one redirect. + // Expected Location: /foo + // Actual Location: /foo?username=romain ← bug + response.redirect('/foo', false) + response.finish() + }) + + const { header } = await supertest(url).get('/?username=romain').redirects(1) + assert.equal(header.location, '/foo') + }) })