MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / createPathWithQueryParams

Function createPathWithQueryParams

packages/web/src/lib/utils.ts:54–65  ·  view source on GitHub ↗
(path: string, ...queryParams: [string, string | null][])

Source from the content-addressed store, hash-verified

52 * @returns The path with the query parameters added.
53 */
54export const createPathWithQueryParams = (path: string, ...queryParams: [string, string | null][]) => {
55 // Filter out undefined values
56
57 queryParams = queryParams.filter(([_key, value]) => value !== null);
58
59 if (queryParams.length === 0) {
60 return path;
61 }
62
63 const queryString = queryParams.map(([key, value]) => `${encodeURIComponent(key)}=${encodeRFC3986URIComponent(value ?? '')}`).join('&');
64 return `${path}?${queryString}`;
65}
66
67// @see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986
68const encodeRFC3986URIComponent = (str: string) => {

Callers 6

useCreateNewChatThreadFunction · 0.90
EditorContextMenuFunction · 0.90
SearchBarFunction · 0.90
SearchResultsPageFunction · 0.90
InvitesListFunction · 0.90

Calls 1

Tested by

no test coverage detected