(str)
| 1605 | var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; |
| 1606 | var parts = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor']; |
| 1607 | function parse(str) { |
| 1608 | if (str.length > 8000) { |
| 1609 | throw "URI too long"; |
| 1610 | } |
| 1611 | var src = str, |
| 1612 | b = str.indexOf('['), |
| 1613 | e = str.indexOf(']'); |
| 1614 | if (b != -1 && e != -1) { |
| 1615 | str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); |
| 1616 | } |
| 1617 | var m = re.exec(str || ''), |
| 1618 | uri = {}, |
| 1619 | i = 14; |
| 1620 | while (i--) { |
| 1621 | uri[parts[i]] = m[i] || ''; |
| 1622 | } |
| 1623 | if (b != -1 && e != -1) { |
| 1624 | uri.source = src; |
| 1625 | uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); |
| 1626 | uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); |
| 1627 | uri.ipv6uri = true; |
| 1628 | } |
| 1629 | uri.pathNames = pathNames(uri, uri['path']); |
| 1630 | uri.queryKey = queryKey(uri, uri['query']); |
| 1631 | return uri; |
| 1632 | } |
| 1633 | function pathNames(obj, path) { |
| 1634 | var regx = /\/{2,9}/g, |
| 1635 | names = path.replace(regx, "/").split("/"); |
no test coverage detected