fix: honor empty URL query and fragment markers (#2091)

URL.search and URL.hash are empty for both a missing component and an explicit empty one, so endpoint and origin checks were accepting URLs the callers meant to reject.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Faheem Ahmad
2026-10-13 06:05:29 +09:00
committed by GitHub
co-authored by Cursor
parent d59ab6d977
commit af29247a78
10 changed files with 62 additions and 14 deletions
+4
View File
@@ -19,6 +19,8 @@ describe("browser observation contracts", () => {
"https://*.example.com",
"https://example.com/path",
"https://example.com/?token=secret",
"https://example.com/?",
"https://example.com/#",
"https://user:pass@example.com",
"file:///tmp/page.html",
])
@@ -37,6 +39,8 @@ describe("browser observation contracts", () => {
"http://192.168.1.2:9222",
"https://127.0.0.1:9222",
"http://127.0.0.1:9222/json/list",
"http://127.0.0.1:9222/?",
"http://127.0.0.1:9222/#",
"http://user:pass@127.0.0.1:9222",
])
expect(browserEndpointSchema.safeParse(value).success, value).toBe(false);