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
+2 -2
View File
@@ -7,6 +7,7 @@ import { AnalysisError } from "../domain/analysisErrorBase.js";
import { BrowserObservationError } from "../domain/browserObservationError.js";
import type { BrowserObservationOperation } from "../domain/browserObservationErrors.js";
import { sanitizeBrowserUrl } from "../domain/browserObservation.js";
import { urlDeclaresQueryOrFragment } from "../domain/urlComponents.js";
import { safeParseJson } from "../domain/safeJson.js";
const endpointVersionSchema = z.object({
@@ -230,8 +231,7 @@ const safeCdpWebSocketEndpoint = (
parsed.port !== trustedEndpoint.port ||
parsed.username !== "" ||
parsed.password !== "" ||
parsed.search !== "" ||
parsed.hash !== "" ||
urlDeclaresQueryOrFragment(parsed) ||
path === undefined
)
throw new BrowserObservationError(operation, "invalid_endpoint_response");