Skip to content

Commit 5bbc7b7

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. Signed-off-by: Charles Queiroz <fcqueiroz@liquibase.com>
1 parent d9f3088 commit 5bbc7b7

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
@@ -1855,8 +1855,22 @@ static void extract_call_args(CBMExtractCtx *ctx, TSNode args, CBMCall *call) {
18551855
ca->index = positional_idx++;
18561856
if (is_string_like(ak) && ca->expr) {
18571857
ca->value = strip_quotes(ctx->arena, ca->expr);
1858+
} else if (strcmp(ak, "template_string") == 0) {
1859+
/* Flattened {} form so downstream url-arg detection joins the
1860+
* canonical server route shape (issue #1006/#1009). */
1861+
ca->value = cbm_template_string_text(ctx->arena, arg_node, ctx->source);
18581862
} else if (strcmp(ak, "identifier") == 0 && ca->expr) {
18591863
ca->value = lookup_string_constant(ctx, ca->expr);
1864+
} else if (strcmp(ak, "call_expression") == 0) {
1865+
/* URL-builder helper call (issue #1009): resolve
1866+
* client(buildPath(id)) through the per-file builder map. */
1867+
TSNode fn = ts_node_child_by_field_name(arg_node, TS_FIELD("function"));
1868+
if (!ts_node_is_null(fn) && strcmp(ts_node_type(fn), "identifier") == 0) {
1869+
char *fname = cbm_node_text(ctx->arena, fn, ctx->source);
1870+
if (fname) {
1871+
ca->value = lookup_string_constant(ctx, fname);
1872+
}
1873+
}
18601874
}
18611875
call->arg_count++;
18621876
}

0 commit comments

Comments
 (0)