MCPcopy Create free account
hub / github.com/rmyndharis/OpenWA / buildUrl

Function buildUrl

sdk/javascript/src/http.ts:58–68  ·  view source on GitHub ↗
(baseUrl: string, path: string, query?: object)

Source from the content-addressed store, hash-verified

56
57/** Build a URL with serialized query params, omitting `undefined`/`null` values. */
58export function buildUrl(baseUrl: string, path: string, query?: object): string {
59 const url = `${baseUrl.replace(/\/$/, '')}${path}`;
60 if (!query) return url;
61 const params = new URLSearchParams();
62 for (const [key, value] of Object.entries(query)) {
63 if (value === undefined || value === null) continue;
64 params.append(key, String(value));
65 }
66 const qs = params.toString();
67 return qs ? `${url}?${qs}` : url;
68}
69
70/**
71 * Perform a single request against the OpenWA API and return the parsed JSON

Callers 1

requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected