Skip to content

Commit

Permalink
Updated the host property so that it is matching Node's interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidTPate committed Aug 8, 2014
1 parent 0d8e9f5 commit 78c87b7
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 91 deletions.
14 changes: 2 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var simplePathPattern = /^(\/?[a-z0-9-._~!$&'()*+,;=:@%\/]+)(\?([a-z0-9!$&'()*+-,;=:#\[\]@\/\?%]+)?)?(#[a-z0-9!$&'()*+,;=:#-\[\]@\/\?%]+)?$/i,
giantPattern = /^([a-z0-9\.\+-]+:)?\/\/(([a-z0-9!$&'()*+-,;=#\[\]@\/\?%]+:[a-z0-9!$&'()*+-,;=#\[\]@\/\?%]+)@)?([a-z0-9\-\.]+)(:([0-9]+))?(\/[a-z0-9-._~!$&'()*+,;=:@%\/]+)(\?[a-z0-9!$&'()*+-,;=:#\[\]@\/\?%]+)(#[a-z0-9!$&'()*+,;=:#-\[\]@\/\?%]+)$/i,
protocolPattern = /^[a-z0-9\.\+-]+:/,
hostnamePartPattern = /([a-z0-9\-]+)\.?/ig,
queryStringPartPattern = /\??([^\?\=\&]+)\=?([^\=\&]+)?/g;

var slash = 0x2F,
Expand Down Expand Up @@ -85,8 +84,8 @@ function decomposeUrl(url, str) {
if (matches) {
url.protocol = matches[1] || null;
url.auth = matches[3] || null;
url.port = matches[6] || null;
decomposeHostname(url, matches[4]);
url.port = matches[6] || '80';
decomposeQueryString(url, matches[8]);
decomposePathname(url, matches[7]);
decomposeHash(url, matches[9]);
Expand All @@ -111,16 +110,7 @@ function decomposeHostname(url, str) {
}

url.hostname = str;
url.host = [];

var matches = hostnamePartPattern.exec(str);
while (matches && hostnamePartPattern.lastIndex) {
if (matches[1]) {
url.host.push(matches[1]);
}
matches = hostnamePartPattern.exec(str);
}

url.host = str + (url.port ? ':' + url.port : '');
return url;
}

Expand Down
Loading

0 comments on commit 78c87b7

Please sign in to comment.