MCPcopy
hub / github.com/sindresorhus/query-string / stringifyUrl

Function stringifyUrl

base.js:553–580  ·  view source on GitHub ↗
(object, options)

Source from the content-addressed store, hash-verified

551}
552
553export function stringifyUrl(object, options) {
554 options = {
555 encode: true,
556 strict: true,
557 [encodeFragmentIdentifier]: true,
558 ...options,
559 };
560
561 const url = getUrlWithoutQuery(removeHash(object.url)) || '';
562 const queryFromUrl = extract(object.url);
563
564 const query = {
565 ...parse(queryFromUrl, {sort: false, ...options}),
566 ...object.query,
567 };
568
569 let queryString = stringify(query, options);
570 queryString &&= `?${queryString}`;
571
572 let hash = getHash(object.url);
573 if (typeof object.fragmentIdentifier === 'string') {
574 const urlObjectForFragmentEncode = new URL(url, 'https://query-string.invalid');
575 urlObjectForFragmentEncode.hash = object.fragmentIdentifier;
576 hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;
577 }
578
579 return `${url}${queryString}${hash}`;
580}
581
582export function pick(input, filter, options) {
583 options = {

Callers 2

benchmark.jsFile · 0.85
pickFunction · 0.85

Calls 6

getUrlWithoutQueryFunction · 0.85
removeHashFunction · 0.85
extractFunction · 0.85
parseFunction · 0.85
stringifyFunction · 0.85
getHashFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…