MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / extract_base_path

Function extract_base_path

src/langfuse/tracer.cpp:32–45  ·  view source on GitHub ↗

Strip the scheme prefix off a Langfuse host URL and return the leading sub-path (everything after the host[:port], e.g. "/langfuse" if hosted under a sub-path). httplib::Client's URL constructor handles host/port/TLS itself, so we only need to extract the optional base path.

Source from the content-addressed store, hash-verified

30// a sub-path). httplib::Client's URL constructor handles host/port/TLS itself,
31// so we only need to extract the optional base path.
32std::string extract_base_path(const std::string& url) {
33 std::string s = url;
34 if (s.starts_with("https://"))
35 s = s.substr(8);
36 else if (s.starts_with("http://"))
37 s = s.substr(7);
38 auto slash = s.find('/');
39 if (slash == std::string::npos)
40 return {};
41 std::string p = s.substr(slash);
42 if (!p.empty() && p.back() == '/')
43 p.pop_back();
44 return p;
45}
46
47// Strip any trailing slash from a scheme+host[:port] URL so httplib's URL ctor
48// gets exactly what it expects.

Callers 1

HttpStateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected