MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / appendQueryParams

Function appendQueryParams

out/cli.cjs:77377–77398  ·  view source on GitHub ↗
(url2, options = {})

Source from the content-addressed store, hash-verified

77375 return routePath;
77376 }
77377 endpoint = buildBaseUrl(endpoint, options);
77378 routePath = buildRoutePath(routePath, pathParameters, options);
77379 const requestUrl = appendQueryParams(`${endpoint}/${routePath}`, options);
77380 const url2 = new URL(requestUrl);
77381 return url2.toString().replace(/([^:]\/)\/+/g, "$1");
77382}
77383function appendQueryParams(url2, options = {}) {
77384 if (!options.queryParameters) {
77385 return url2;
77386 }
77387 let parsedUrl = new URL(url2);
77388 const queryParams = options.queryParameters;
77389 for (const key of Object.keys(queryParams)) {
77390 const param = queryParams[key];
77391 if (param === void 0 || param === null) {
77392 continue;
77393 }
77394 if (!param.toString || typeof param.toString !== "function") {
77395 throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);
77396 }
77397 const value = param.toISOString !== void 0 ? param.toISOString() : param.toString();
77398 parsedUrl.searchParams.append(key, value);
77399 }
77400 if (options.skipUrlEncoding) {
77401 parsedUrl = skipQueryParameterEncoding(parsedUrl);

Callers 1

buildRequestUrlFunction · 0.85

Calls 4

keysMethod · 0.45
toStringMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected