Skip to content

Commit 9d58769

Browse files
fix: resolve builder calls and template literals in per-arg values too
detect_url_in_args() (the arg_url HTTP_CALLS emitter used when the callee is a local client wrapper, not a known HTTP library) reads per-arg values, not first_string_arg. Resolve call_expression args through the builder map and flatten template_string args to the {} form there as well, so wrappers like apiFetch(buildPath(id)) emit the edge and join the canonical route.
1 parent a350bb7 commit 9d58769

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

internal/cbm/extract_calls.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,8 +1355,22 @@ static void extract_call_args(CBMExtractCtx *ctx, TSNode args, CBMCall *call) {
13551355
ca->index = positional_idx++;
13561356
if (is_string_like(ak) && ca->expr) {
13571357
ca->value = strip_quotes(ctx->arena, ca->expr);
1358+
} else if (strcmp(ak, "template_string") == 0) {
1359+
/* Flattened {} form so downstream url-arg detection joins the
1360+
* canonical server route shape (issue #1006/#1009). */
1361+
ca->value = cbm_template_string_text(ctx->arena, arg_node, ctx->source);
13581362
} else if (strcmp(ak, "identifier") == 0 && ca->expr) {
13591363
ca->value = lookup_string_constant(ctx, ca->expr);
1364+
} else if (strcmp(ak, "call_expression") == 0) {
1365+
/* URL-builder helper call (issue #1009): resolve
1366+
* client(buildPath(id)) through the per-file builder map. */
1367+
TSNode fn = ts_node_child_by_field_name(arg_node, TS_FIELD("function"));
1368+
if (!ts_node_is_null(fn) && strcmp(ts_node_type(fn), "identifier") == 0) {
1369+
char *fname = cbm_node_text(ctx->arena, fn, ctx->source);
1370+
if (fname) {
1371+
ca->value = lookup_string_constant(ctx, fname);
1372+
}
1373+
}
13601374
}
13611375
call->arg_count++;
13621376
}

0 commit comments

Comments
 (0)