just.parseUrl(urlopt) → {url_parts}
Parses url without checking if it's a valid url.
Note that this function uses window.location to make relative urls, so
weird values in there will give weird results.
Parameters:
Name
Type
Default
Description
url
[optional]
url
window.location.href
A relative, an absolute or a blob url.
Returns:
-
Type
-
url_parts
Examples
Name | Type | Default | Description |
---|---|---|---|
url
[optional] |
url | window.location.href | A relative, an absolute or a blob url. |
parseUrl(window.location.href);
parseUrl('/?a#c?d'); // "/" is the pathname, "?a" the search and "#c?d" the hash.
parseUrl('blob:'); // Same as 'blob:' + `window.location.href`
parseUrl(); // Same as `window.location`.
parseUrl('a'); // Something that doesn't start with "/", "?", or "#" is evaluated as a host.
parseUrl('a:b'); // "a:b" is a host, since "b" is not a number.
parseUrl('//'); // evals as the current origin.
parseUrl('blob://'); // Same as 'blob:' + `window.location.origin`.
// [...]