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

Function cbm_extract_path_from_url

src/traces/traces.c:30–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28/* ── extractPathFromURL ──────────────────────────────────────────── */
29
30const char *cbm_extract_path_from_url(const char *url, char *buf, size_t buf_sz) {
31 if (!url || !buf || buf_sz == 0) {
32 if (buf) {
33 buf[0] = '\0';
34 }
35 return buf ? buf : "";
36 }
37
38 /* Find the third '/' which starts the path: https://host/path */
39 int slashes = 0;
40 int idx = TRACE_NOT_FOUND;
41 for (int i = 0; url[i]; i++) {
42 if (url[i] == '/') {
43 slashes++;
44 if (slashes == TRACE_PATH_SLASHES) {
45 idx = i;
46 break;
47 }
48 }
49 }
50 if (idx < 0) {
51 buf[0] = '\0';
52 return buf;
53 }
54
55 /* Copy path, stopping at '?' */
56 size_t j = 0;
57 for (int i = idx; url[i] && url[i] != '?' && j < buf_sz - SKIP_ONE; i++) {
58 buf[j++] = url[i];
59 }
60 buf[j] = '\0';
61 return buf;
62}
63
64/* ── parseDuration ───────────────────────────────────────────────── */
65

Callers 2

cbm_extract_http_infoFunction · 0.85
test_traces.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected