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) {
1414 if ( ! params . host && params . hostname ) {
1515 params . host = params . hostname ;
1616 }
17-
17+
18+ if ( params . protocol ) {
19+ params . scheme = params . protocol . split ( ':' ) [ 0 ] ;
20+ }
21+
1822 if ( ! params . scheme ) params . scheme = window . location . protocol . split ( ':' ) [ 0 ] ;
1923 if ( ! params . host ) {
2024 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) {
4848
4949} ) ;
5050
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+ } ) ;
5165
5266test ( 'Test string as parameters' , function ( t ) {
5367 var url = '/api/foo' ;
You can’t perform that action at this time.
0 commit comments