comunicationLeap/node_modules/parseuri/index.js
node_modules/parseuri/index.jsRaw
1/**
2 * Parses an URI
3 *
4 * @author Steven Levithan <stevenlevithan.com> (MIT license)
5 * @api private
6 */
7
8var re = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
9
10var parts = [
11 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host'
12 , 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'
13];
14
15module.exports = function parseuri(str) {
16 var m = re.exec(str || '')
17 , uri = {}
18 , i = 14;
19
20 while (i--) {
21 uri[parts[i]] = m[i] || '';
22 }
23
24 return uri;
25};