MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / nest_path_from_string

Function nest_path_from_string

internal/cbm/extract_defs.c:3250–3264  ·  view source on GitHub ↗

Unquote a TS `string` literal node and root it at "/": Nest writes route * segments without a leading slash (@Get(':id'), @Controller('users')). */

Source from the content-addressed store, hash-verified

3248/* Unquote a TS `string` literal node and root it at "/": Nest writes route
3249 * segments without a leading slash (@Get(':id'), @Controller('users')). */
3250static const char *nest_path_from_string(CBMArena *a, TSNode node, const char *source) {
3251 if (ts_node_is_null(node) || strcmp(ts_node_type(node), "string") != 0) {
3252 return NULL;
3253 }
3254 char *text = cbm_node_text(a, node, source);
3255 size_t len = text ? strlen(text) : 0;
3256 if (len < PAIR_CHARS) {
3257 return NULL;
3258 }
3259 const char *inner = cbm_arena_strndup(a, text + SKIP_CHAR, len - PAIR_CHARS);
3260 if (!inner) {
3261 return NULL;
3262 }
3263 return inner[0] == '/' ? inner : cbm_arena_sprintf(a, "/%s", inner);
3264}
3265
3266/* The route path a Nest decorator's argument list carries. Accepted shapes:
3267 * () -> "/"

Callers 1

nest_path_from_argsFunction · 0.85

Calls 3

cbm_node_textFunction · 0.85
cbm_arena_strndupFunction · 0.70
cbm_arena_sprintfFunction · 0.70

Tested by

no test coverage detected