From 0e4f17d279ee8a5ad3c97182d4193bce424c8e5d Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Fri, 10 Nov 2023 20:09:47 -0500 Subject: [PATCH] Add tests for routes with trailing slashes (prevent #480 incident again) --- test/worker.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/worker.test.ts b/test/worker.test.ts index 89d0016..74bc2e5 100644 --- a/test/worker.test.ts +++ b/test/worker.test.ts @@ -58,6 +58,17 @@ test('Tweet redirect human', async () => { expect(result.headers.get('location')).toEqual('https://twitter.com/jack/status/20'); }); +test('Tweet redirect human trailing slash', async () => { + const result = await app.request( + new Request('https://fxtwitter.com/jack/status/20/', { + method: 'GET', + headers: humanHeaders + }) + ); + expect(result.status).toEqual(302); + expect(result.headers.get('location')).toEqual('https://twitter.com/jack/status/20'); +}); + test('Tweet redirect human custom base redirect', async () => { const result = await app.request( new Request('https://fxtwitter.com/jack/status/20', { @@ -96,6 +107,16 @@ test('Tweet response robot', async () => { expect(result.status).toEqual(200); }); +test('Tweet response robot (trailing slash/query string)', async () => { + const result = await app.request( + new Request('https://fxtwitter.com/jack/status/20/?asdf=ghjk&klop;', { + method: 'GET', + headers: botHeaders + }) + ); + expect(result.status).toEqual(200); +}); + test('API fetch basic Tweet', async () => { const result = await app.request( new Request('https://api.fxtwitter.com/status/20', {