1 | ;
|
2 |
|
3 | const Url = require("url");
|
4 |
|
5 | module.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 | };
|