MCPcopy Index your code
hub / github.com/nodejs/node / serializePathWithQuery

Function serializePathWithQuery

deps/undici/src/lib/core/util.js:107–119  ·  view source on GitHub ↗

* @param {string} url The URL to add the query params to * @param {import('node:querystring').ParsedUrlQueryInput} queryParams The object to serialize into a URL query string * @returns {string} The URL with the query params added

(url, queryParams)

Source from the content-addressed store, hash-verified

105 * @returns {string} The URL with the query params added
106 */
107function serializePathWithQuery (url, queryParams) {
108 if (pathHasQueryOrFragment(url)) {
109 throw new Error('Query params cannot be passed when url already contains "?" or "#".')
110 }
111
112 const stringified = stringify(queryParams)
113
114 if (stringified) {
115 url += '?' + stringified
116 }
117
118 return url
119}
120
121/**
122 * @param {number|string|undefined} port

Callers 4

constructorMethod · 0.70
constructorMethod · 0.50
getMockDispatchFunction · 0.50
makeCacheKeyFunction · 0.50

Calls 2

pathHasQueryOrFragmentFunction · 0.70
stringifyFunction · 0.50

Tested by

no test coverage detected