From 25733440ceea6038b5351b112d732e81ee6e247e Mon Sep 17 00:00:00 2001 From: workers-devprod <116369605+workers-devprod@users.noreply.github.com> Date: Sat, 14 Nov 2026 05:46:53 +0000 Subject: [PATCH] test(workers-shared): failing test for #16924 parseRedirects appends a trailing slash after the querystring or fragment of absolute _redirects targets without a path, e.g. https://example.com?utm=1 becomes https://example.com?utm=1/ instead of https://example.com/?utm=1. --- .../utils/tests/parseRedirects.valid.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/workers-shared/utils/tests/parseRedirects.valid.test.ts b/packages/workers-shared/utils/tests/parseRedirects.valid.test.ts index d3336c283c..08b446f0dc 100644 --- a/packages/workers-shared/utils/tests/parseRedirects.valid.test.ts +++ b/packages/workers-shared/utils/tests/parseRedirects.valid.test.ts @@ -257,6 +257,40 @@ test("parseRedirects should accept going to absolute URLs with ports", ({ }); }); +test("parseRedirects should not append a slash after the querystring or fragment of absolute URLs without a path", ({ + expect, +}) => { + const input = ` + /a https://example.com?utm=1 + /b https://example.com#section + /c https://example.com?utm=1#section 301 + `; + const result = parseRedirects(input); + expect(result).toEqual({ + rules: [ + { + from: "/a", + status: 302, + to: "https://example.com/?utm=1", + lineNumber: 2, + }, + { + from: "/b", + status: 302, + to: "https://example.com/#section", + lineNumber: 3, + }, + { + from: "/c", + status: 301, + to: "https://example.com/?utm=1#section", + lineNumber: 4, + }, + ], + invalid: [], + }); +}); + test("parseRedirects should accept relative URLs that don't point to .html files", ({ expect, }) => {