MCPcopy Create free account
hub / github.com/nodejs/node / URLSerializer

Function URLSerializer

deps/undici/src/lib/web/fetch/data-url.js:123–138  ·  view source on GitHub ↗

* @param {URL} url * @param {boolean} excludeFragment

(url, excludeFragment = false)

Source from the content-addressed store, hash-verified

121 * @param {boolean} excludeFragment
122 */
123function URLSerializer (url, excludeFragment = false) {
124 if (!excludeFragment) {
125 return url.href
126 }
127
128 const href = url.href
129 const hashLength = url.hash.length
130
131 const serialized = hashLength === 0 ? href : href.substring(0, href.length - hashLength)
132
133 if (!hashLength && href.endsWith('#')) {
134 return serialized.slice(0, -1)
135 }
136
137 return serialized
138}
139
140// https://url.spec.whatwg.org/#string-percent-decode
141/** @param {string} input */

Callers 6

dataURLProcessorFunction · 0.70
urlMethod · 0.70
redirectMethod · 0.70
urlMethod · 0.70
urlEqualsFunction · 0.50
urlMethod · 0.50

Calls 1

sliceMethod · 0.65

Tested by

no test coverage detected