| 1791 | var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; |
| 1792 | var parts = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor']; |
| 1793 | function parse(str) { |
| 1794 | var src = str, |
| 1795 | b = str.indexOf('['), |
| 1796 | e = str.indexOf(']'); |
| 1797 | if (b != -1 && e != -1) { |
| 1798 | str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length); |
| 1799 | } |
| 1800 | var m = re.exec(str || ''), |
| 1801 | uri = {}, |
| 1802 | i = 14; |
| 1803 | while (i--) { |
| 1804 | uri[parts[i]] = m[i] || ''; |
| 1805 | } |
| 1806 | if (b != -1 && e != -1) { |
| 1807 | uri.source = src; |
| 1808 | uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':'); |
| 1809 | uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':'); |
| 1810 | uri.ipv6uri = true; |
| 1811 | } |
| 1812 | uri.pathNames = pathNames(uri, uri['path']); |
| 1813 | uri.queryKey = queryKey(uri, uri['query']); |
| 1814 | return uri; |
| 1815 | } |
| 1816 | function pathNames(obj, path) { |
| 1817 | var regx = /\/{2,9}/g, |
| 1818 | names = path.replace(regx, "/").split("/"); |