2019-10-09 21:35:13 +02:00
|
|
|
/* eslint no-useless-escape: 0*/
|
2020-03-14 01:46:14 +02:00
|
|
|
/* eslint prefer-const: 0*/
|
2019-07-30 09:35:42 +02:00
|
|
|
|
2017-11-28 23:49:58 +02:00
|
|
|
// parseUri 1.2.2
|
|
|
|
// (c) Steven Levithan <stevenlevithan.com>
|
|
|
|
// MIT License
|
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
function parseUri(str) {
|
2020-03-14 01:46:14 +02:00
|
|
|
let o = parseUri.options,
|
2019-07-29 15:43:53 +02:00
|
|
|
m = o.parser[o.strictMode ? 'strict' : 'loose'].exec(str),
|
2017-11-28 23:49:58 +02:00
|
|
|
uri = {},
|
2019-07-29 15:43:53 +02:00
|
|
|
i = 14;
|
2017-11-28 23:49:58 +02:00
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
while (i--) uri[o.key[i]] = m[i] || '';
|
2017-11-28 23:49:58 +02:00
|
|
|
|
|
|
|
uri[o.q.name] = {};
|
2019-07-29 15:43:53 +02:00
|
|
|
uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) {
|
2017-11-28 23:49:58 +02:00
|
|
|
if ($1) uri[o.q.name][$1] = $2;
|
|
|
|
});
|
|
|
|
|
|
|
|
return uri;
|
2019-07-29 15:43:53 +02:00
|
|
|
}
|
2017-11-28 23:49:58 +02:00
|
|
|
|
|
|
|
parseUri.options = {
|
|
|
|
strictMode: false,
|
2019-07-29 15:43:53 +02:00
|
|
|
key: ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'],
|
|
|
|
q: {
|
|
|
|
name: 'queryKey',
|
|
|
|
parser: /(?:^|&)([^&=]*)=?([^&]*)/g,
|
2017-11-28 23:49:58 +02:00
|
|
|
},
|
|
|
|
parser: {
|
|
|
|
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
2019-07-29 15:43:53 +02:00
|
|
|
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
|
|
|
},
|
2017-11-28 23:49:58 +02:00
|
|
|
};
|
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
module.exports = parseUri;
|