MCPcopy Create free account
hub / github.com/langgenius/dify / appendSearchParams

Function appendSearchParams

cli/src/http/url.ts:26–41  ·  view source on GitHub ↗
(url: string, params: Record<string, SearchParamValue> | undefined)

Source from the content-addressed store, hash-verified

24// do that for them, on purpose, so a caller that wants to send an explicit
25// empty value still can.
26export function appendSearchParams(url: string, params: Record<string, SearchParamValue> | undefined): string {
27 if (params === undefined)
28 return url
29
30 const search = new URLSearchParams()
31 for (const [key, value] of Object.entries(params)) {
32 if (value === undefined)
33 continue
34 search.append(key, String(value))
35 }
36
37 const qs = search.toString()
38 if (qs === '')
39 return url
40 return url.includes('?') ? `${url}&${qs}` : `${url}?${qs}`
41}

Callers 2

buildRequestFunction · 0.70
url.test.tsFile · 0.70

Calls 4

entriesMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45
includesMethod · 0.45

Tested by

no test coverage detected