This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
uri_parser.js
60 lines (40 loc) · 1.56 KB
/
uri_parser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var UriParser;
UriParser = (function() {
UriParser.name = 'UriParser';
UriParser.prototype._regExp = /^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#;\|]+)?([;\|])?([^\?#]+)?\??([^#]+)?#?(\w*)/;
UriParser.prototype.username = '';
UriParser.prototype.password = '';
UriParser.prototype.port = '';
UriParser.prototype.protocol = '';
UriParser.prototype.host = '';
UriParser.prototype.pathname = '';
UriParser.prototype.url = '';
UriParser.prototype.urlparamseparator = '';
UriParser.prototype.urlparam = '';
UriParser.prototype.querystring = {};
UriParser.prototype.fragment = '';
UriParser.prototype.results = null;
function UriParser(uri) {
if (uri != null) this.parse(uri);
}
UriParser.prototype._getVal = function(r, i) {
if ((r != null ? r[i] : void 0) != null) return r[i];
};
UriParser.prototype.parse = function(uri) {
if (uri == null) return null;
this.results = this._regExp.exec(uri);
this.url = this._getVal(this.results, 0);
this.protocol = this._getVal(this.results, 2);
this.username = this._getVal(this.results, 4);
this.password = this._getVal(this.results, 5);
this.host = this._getVal(this.results, 6);
this.port = this._getVal(this.results, 7);
this.pathname = this._getVal(this.results, 8);
this.urlparamseparator = this._getVal(this.results, 9);
this.urlparam = this._getVal(this.results, 10);
this.querystring = this._getVal(this.results, 11);
this.fragment = this._getVal(this.results, 12);
return this.results;
};
return UriParser;
})();