Fix ports when connecting to 80/443 from non-80/443 host

This commit is contained in:
Kevin Ingersoll
2014-04-06 21:26:38 +12:00
parent 1efe0d05c5
commit 67d077af2e

View File

@@ -51,9 +51,13 @@ function url(uri, loc){
}
// make sure we treat `localhost:80` and `localhost` equally
if ((/(http|ws)/.test(obj.protocol) && 80 == obj.port) ||
(/(http|ws)s/.test(obj.protocol) && 443 == obj.port)) {
delete obj.port;
if (null == obj.port) {
if (/^(http|ws):$/.test(obj.protocol)) {
obj.port = 80;
}
else if (/^(http|ws)s:$/.test(obj.protocol)) {
obj.port = 443;
}
}
obj.path = obj.path || '/';