diff --git a/src/domain/javascriptStaticAnalysisHelpers.ts b/src/domain/javascriptStaticAnalysisHelpers.ts index 879ac96a7..0109dead9 100644 --- a/src/domain/javascriptStaticAnalysisHelpers.ts +++ b/src/domain/javascriptStaticAnalysisHelpers.ts @@ -423,12 +423,15 @@ export const endpointArgument = ( // `XMLHttpRequest.open(method, url)`. if (name.endsWith(".open") && isXhrMethodArgument(args[0])) return stringValue(args[1]); - if ( - ["get", "post", "put", "patch", "delete", "request"].some( - (method) => name === method || name.endsWith(`.${method}`), - ) - ) - return isKeyedCollectionReceiver(callee) ? undefined : stringValue(args[0]); + const method = ["get", "post", "put", "patch", "delete", "request"].find( + (candidate) => name === candidate || name.endsWith(`.${candidate}`), + ); + if (method !== undefined) + // Only get and delete also belong to the keyed-collection APIs. + return (method === "get" || method === "delete") && + isKeyedCollectionReceiver(callee) + ? undefined + : stringValue(args[0]); if (name.endsWith("loadURL")) return stringValue(args[0]); return undefined; }; diff --git a/src/domain/webBundleAnalyzer.test.ts b/src/domain/webBundleAnalyzer.test.ts index 121c75093..279785546 100644 --- a/src/domain/webBundleAnalyzer.test.ts +++ b/src/domain/webBundleAnalyzer.test.ts @@ -203,11 +203,19 @@ describe("web bundle static-analysis parity", () => { response.headers.get("content-type"); request?.headers.delete("cookie"); new URL(location.href).searchParams.get("page"); + api.headers.post("/v1/headers"); + api.searchParams.request("/search"); `), ); expect( result.observations.endpoints.map(({ value }) => value).sort(), - ).toEqual(["cache-key", "https://api.example.test/users", "users"]); + ).toEqual([ + "/search", + "/v1/headers", + "cache-key", + "https://api.example.test/users", + "users", + ]); }); it("recognizes loadURL endpoints like static analysis", () => {