Skip to content

Commit 5ab0492

Browse files
author
James Halliday
committed
only take the window.location.port when params.host isn't passed in
1 parent 826781d commit 5ab0492

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ var Request = require('./lib/request');
44

55
http.request = function (params, cb) {
66
if (!params) params = {};
7-
if (!params.host) params.host = window.location.host.split(':')[0];
8-
if (!params.port) params.port = window.location.port;
7+
if (!params.host && !params.port) {
8+
params.port = parseInt(window.location.port, 10);
9+
}
10+
if (!params.host) params.host = window.location.hostname;
11+
if (!params.port) params.port = 80;
912
if (!params.scheme) params.scheme = window.location.protocol.split(':')[0];
1013

1114
var req = new Request(new xhrHttp, params);

0 commit comments

Comments
 (0)