MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / buildUrl

Function buildUrl

src/lib/http.ts:664–678  ·  view source on GitHub ↗
(
  baseUrl: string,
  path: string,
  query?: Record<string, string | number | boolean | undefined>,
)

Source from the content-addressed store, hash-verified

662}
663
664export function buildUrl(
665 baseUrl: string,
666 path: string,
667 query?: Record<string, string | number | boolean | undefined>,
668): string {
669 const normalizedPath = path.startsWith('/') ? path : `/${path}`;
670 const url = new URL(`${trimTrailingSlash(baseUrl)}${normalizedPath}`);
671 if (query) {
672 for (const [key, value] of Object.entries(query)) {
673 if (value === undefined) continue;
674 url.searchParams.set(key, String(value));
675 }
676 }
677 return url.toString();
678}
679
680function newRequestId(): string {
681 return `cli_${randomUUID()}`;

Callers 2

requestWithMetaMethod · 0.85
http.test.tsFile · 0.85

Calls 1

trimTrailingSlashFunction · 0.85

Tested by

no test coverage detected