Permalink
Browse files

Only use scheme if no protocol is provided

  • Loading branch information...
1 parent 2fdbcd2 commit cf4f5a82292bb50fc94b09d335c6d6cefa4c5264 @tschaub tschaub committed Sep 2, 2014
Showing with 8 additions and 5 deletions.
  1. +7 −4 index.js
  2. +1 −1 lib/request.js
View
@@ -15,11 +15,14 @@ http.request = function (params, cb) {
params.host = params.hostname;
}
- if (params.protocol) {
- params.scheme = params.protocol.split(':')[0];
+ if (!params.protocol) {
+ if (params.scheme) {
+ params.protocol = params.scheme + ':';
+ } else {
+ params.protocol = window.location.protocol;
+ }
}
- if (!params.scheme) params.scheme = window.location.protocol.split(':')[0];
if (!params.host) {
params.host = window.location.hostname || window.location.host;
}
@@ -29,7 +32,7 @@ http.request = function (params, cb) {
}
params.host = params.host.split(':')[0];
}
- if (!params.port) params.port = params.scheme == 'https' ? 443 : 80;
+ if (!params.port) params.port = params.protocol == 'https:' ? 443 : 80;
var req = new Request(new xhrHttp, params);
if (cb) req.on('response', cb);
View
@@ -9,7 +9,7 @@ var Request = module.exports = function (xhr, params) {
self.xhr = xhr;
self.body = [];
- self.uri = (params.scheme || 'http') + '://'
+ self.uri = (params.protocol || 'http:') + '//'
+ params.host
+ (params.port ? ':' + params.port : '')
+ (params.path || '/')

0 comments on commit cf4f5a8

Please sign in to comment.