File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,11 @@ http.request = function (params, cb) {
14
14
if ( ! params . host && params . hostname ) {
15
15
params . host = params . hostname ;
16
16
}
17
-
17
+
18
+ if ( params . protocol ) {
19
+ params . scheme = params . protocol . split ( ':' ) [ 0 ] ;
20
+ }
21
+
18
22
if ( ! params . scheme ) params . scheme = window . location . protocol . split ( ':' ) [ 0 ] ;
19
23
if ( ! params . host ) {
20
24
params . host = window . location . hostname || window . location . host ;
Original file line number Diff line number Diff line change @@ -48,6 +48,20 @@ test('Test full url object', function(t) {
48
48
49
49
} ) ;
50
50
51
+ test ( 'Test alt protocol' , function ( t ) {
52
+ var params = {
53
+ protocol : "foo:" ,
54
+ hostname : "localhost" ,
55
+ port : "3000" ,
56
+ path : "/bar"
57
+ } ;
58
+
59
+ var request = http . get ( params , noop ) ;
60
+
61
+ t . equal ( request . uri , 'foo://localhost:3000/bar' , 'Url should be correct' ) ;
62
+ t . end ( ) ;
63
+
64
+ } ) ;
51
65
52
66
test ( 'Test string as parameters' , function ( t ) {
53
67
var url = '/api/foo' ;
You can’t perform that action at this time.
0 commit comments