fix(javascript): qualify network receiver evidence

This commit is contained in:
morluto committed 2026-10-27 09:24:22 +08:00
1 parent a293738c66
commit 25b69bb803
9 files changed
+323 -60

No files matched your search

@@ -675,10 +675,10 @@ export const endpointArgument = (
callee: t.Node,
receiverFact?: JavaScriptOpenReceiverFact,
): JavaScriptEndpointArgument | undefined => {
const literal = (
const candidate = (
value: string | undefined,
): JavaScriptEndpointArgument | undefined =>
value === undefined ? undefined : { kind: "endpoint", value };
value === undefined ? undefined : { kind: "candidate", value };
if (receiverFact === "window") return undefined;
if (
name === "fetch" ||
@@ -687,17 +687,11 @@ export const endpointArgument = (
name === "EventSource" ||
name.endsWith(".EventSource")
)
return literal(stringValue(args[0]));
return candidate(stringValue(args[0]));
if (name.endsWith(".open")) {
const value = xhrOpenUrl(name, args[0], args[1], receiverFact);
if (value === undefined) return undefined;
return {
kind:
stringValue(args[0]) !== undefined || isRequestUrlReference(value)
? "endpoint"
: "candidate",
value,
};
return { kind: "candidate", value };
}
const method = ["get", "post", "put", "patch", "delete", "request"].find(
(candidate) => name === candidate || name.endsWith(`.${candidate}`),
@@ -717,17 +711,10 @@ export const endpointArgument = (
receiverFact === "extension-state")))
)
return undefined;
return {
kind:
method !== "get" && method !== "delete" && isRequestUrlReference(value)
? "endpoint"
: "candidate",
value,
};
return { kind: "candidate", value };
}
// Beacon URLs are endpoint observations, retaining the upstream API support.
if (name === "sendBeacon" || name.endsWith(".sendBeacon"))
return literal(stringValue(args[0]));
return candidate(stringValue(args[0]));
if (name === "loadURL" || name.endsWith(".loadURL")) {
const value = stringValue(args[0]);
return value === undefined ? undefined : { kind: "candidate", value };