fix(javascript): read the target of method-first request(method, url) calls

endpointArgument takes the first literal of a get/post/put/patch/delete/request
call as its endpoint candidate. Method-first clients (superagent's
request(method, url), needle.request, Angular HttpClient.request) put the HTTP
method there, so Api.request("get", "/api/v1/profile") reported the candidate
"get" in both analyze_javascript_application and analyze_web_bundle, and the
path was lost.

For a request callee whose first literal is a standard HTTP method (the
XHR_METHODS set that xhrOpenUrl uses, compared after toUpperCase), an exact
second string is now the candidate. A computed target keeps the method token,
so request("POST", target) is unchanged, as are RPC names, Octokit route
strings and URL-first calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pedrocormannandClaude Opus 5.5 authored and Ysopwnable committed 2026-11-21 22:29:49 +01:00
1 parent fe8e571f78
commit 73bc6f48c7
4 files changed
+100 -1

No files matched your search

@@ -466,6 +466,12 @@ while locally shadowed receivers can still contribute network endpoint
candidates. A template recovered with a parser error and no cooked value stays
dynamic; its raw spelling is not treated as a valid JavaScript string.
Method-first `request` calls, as in superagent, needle, and Angular
`HttpClient`, pass a standard HTTP method, in any letter case, before the
target. In both `analyze_javascript_application` and `analyze_web_bundle`,
`request("get", "/api/users")` contributes `/api/users` as the network endpoint
candidate. When the target is computed, the method token remains the candidate.
RPC client syntax also contributes network endpoint candidates, in both
`analyze_javascript_application` and `analyze_web_bundle`, distinguished by
`mechanism`: