MCPcopy Create free account
hub / github.com/sindresorhus/query-string / parseUrl

Function parseUrl

base.js:682–702  ·  view source on GitHub ↗
(url, options)

Source from the content-addressed store, hash-verified

680}
681
682export function parseUrl(url, options) {
683 options = {
684 decode: true,
685 ...definedOptions(options),
686 };
687
688 // Leading and trailing whitespace is ignored, like `parse()` does for the query and the URL parser does for the whole URL. Otherwise a newline from pasted input would end up in `fragmentIdentifier`.
689 url = url.trim();
690
691 let [url_, hash] = splitOnFirst(url, '#');
692
693 if (url_ === undefined) {
694 url_ = url;
695 }
696
697 return {
698 url: getUrlWithoutQuery(url_),
699 query: parse(extract(url), options),
700 ...(options.parseFragmentIdentifier && hash && {fragmentIdentifier: decode(hash, options)}),
701 };
702}
703
704export function stringifyUrl(object, options) {
705 options = {

Callers 1

pickFunction · 0.85

Calls 5

definedOptionsFunction · 0.85
getUrlWithoutQueryFunction · 0.85
parseFunction · 0.85
extractFunction · 0.85
decodeFunction · 0.85

Tested by

no test coverage detected