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

Function URLSerializer

lib/internal/data_url.js:140–155  ·  view source on GitHub ↗

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

(url, excludeFragment = false)

Source from the content-addressed store, hash-verified

138 * @returns {string}
139 */
140function URLSerializer(url, excludeFragment = false) {
141 const { href } = url;
142
143 if (!excludeFragment) {
144 return href;
145 }
146
147 const hashLength = url.hash.length;
148 const serialized = hashLength === 0 ? href : StringPrototypeSlice(href, 0, href.length - hashLength);
149
150 if (!hashLength && href[href.length - 1] === '#') {
151 return StringPrototypeSlice(serialized, 0, -1);
152 }
153
154 return serialized;
155}
156
157/**
158 * A faster collectASequenceOfCodePoints that only works when comparing a single character.

Callers 1

dataURLProcessorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…