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

Function normalize_url_arg

src/pipeline/pass_parallel.c:2446–2477  ·  view source on GitHub ↗

Normalize a template literal URL and reject junk patterns. * Returns true if norm contains a valid API path. */

Source from the content-addressed store, hash-verified

2444/* Normalize a template literal URL and reject junk patterns.
2445 * Returns true if norm contains a valid API path. */
2446static bool normalize_url_arg(const char *url, char *norm, int norm_sz) {
2447 int ni = 0;
2448 const char *p = url;
2449 if (*p == '`' || *p == '"' || *p == '\'') {
2450 p++;
2451 }
2452 if (*p != '/') {
2453 return false;
2454 }
2455 while (*p && ni < norm_sz - PAIR_LEN) {
2456 if (*p == '$' && *(p + SKIP_ONE) == '{') {
2457 norm[ni++] = ':';
2458 p += PAIR_LEN;
2459 while (*p && *p != '}' && ni < norm_sz - PAIR_LEN) {
2460 norm[ni++] = *p++;
2461 }
2462 if (*p == '}') {
2463 p++;
2464 }
2465 } else if (*p == '`' || *p == '"' || *p == '\'' || *p == '?') {
2466 break;
2467 } else {
2468 norm[ni++] = *p++;
2469 }
2470 }
2471 norm[ni] = '\0';
2472 enum { MIN_URL_LEN = 4 };
2473 if (ni < MIN_URL_LEN || !strchr(norm + SKIP_ONE, '/')) {
2474 return false;
2475 }
2476 return !is_junk_url(norm);
2477}
2478
2479static bool arg_is_topic(const CBMCallArg *arg) {
2480 static const char *keywords[] = {"topic", "topic_id", "topic_name", "queue", "queue_name",

Callers 1

detect_url_in_argsFunction · 0.85

Calls 1

is_junk_urlFunction · 0.85

Tested by

no test coverage detected