UNPKG

348 BJavaScriptView Raw
1"use strict";
2
3const Url = require("url");
4
5module.exports = function getLocation(uri) {
6 if (!uri) return;
7 const {hash, host, hostname, href, pathname, port, protocol, search} = Url.parse(uri);
8
9 return {
10 hash,
11 host,
12 hostname,
13 href,
14 pathname,
15 port,
16 protocol,
17 search,
18 origin: `${protocol}//${host}`,
19 };
20};