File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,20 @@ http.request = function (params, cb) {
7
7
if ( ! params . host && ! params . port ) {
8
8
params . port = parseInt ( window . location . port , 10 ) ;
9
9
}
10
+ if ( ! params . host && params . hostname ) {
11
+ params . host = params . hostname ;
12
+ }
13
+
10
14
if ( ! params . scheme ) params . scheme = window . location . protocol . split ( ':' ) [ 0 ] ;
11
- if ( ! params . host ) params . host = window . location . hostname ;
15
+ if ( ! params . host ) {
16
+ params . host = window . location . hostname || window . location . host ;
17
+ }
18
+ if ( / : / . test ( params . host ) ) {
19
+ if ( ! params . port ) {
20
+ params . port = params . host . split ( ':' ) [ 1 ] ;
21
+ }
22
+ params . host = params . host . split ( ':' ) [ 0 ] ;
23
+ }
12
24
if ( ! params . port ) params . port = params . scheme == 'https' ? 443 : 80 ;
13
25
14
26
var req = new Request ( new xhrHttp , params ) ;
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ var Request = module.exports = function (xhr, params) {
10
10
self . xhr = xhr ;
11
11
self . body = concatStream ( )
12
12
13
- var uri = params . host
13
+ self . uri = ( params . scheme || 'http' ) + '://'
14
+ + params . host
14
15
+ ( params . port ? ':' + params . port : '' )
15
16
+ ( params . path || '/' )
16
17
;
@@ -19,7 +20,7 @@ var Request = module.exports = function (xhr, params) {
19
20
20
21
xhr . open (
21
22
params . method || 'GET' ,
22
- ( params . scheme || 'http' ) + '://' + uri ,
23
+ self . uri ,
23
24
true
24
25
) ;
25
26
You can’t perform that action at this time.
0 commit comments