File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,14 @@ global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
4
4
var noConflictSelf = global . self ;
5
5
global . self = { } ;
6
6
require ( 'whatwg-fetch' ) ;
7
- global . fetch = global . self . fetch ;
8
7
global . Headers = global . self . Headers ;
9
8
global . Request = global . self . Request ;
10
9
global . Response = global . self . Response ;
10
+ var realFetch = global . self . fetch ;
11
+ global . fetch = function ( url , options ) {
12
+ if ( / ^ \/ \/ / . test ( url ) ) {
13
+ url = 'https:' + url ;
14
+ }
15
+ return realFetch . call ( this , url , options ) ;
16
+ } ;
11
17
global . self = noConflictSelf ;
Original file line number Diff line number Diff line change @@ -28,21 +28,23 @@ describe('fetch', function() {
28
28
} ) ;
29
29
30
30
it ( 'should facilitate the making of requests' , function ( done ) {
31
- fetch ( 'https: //mattandre.ws/succeed.txt' )
31
+ fetch ( '//mattandre.ws/succeed.txt' )
32
32
. then ( responseToText )
33
33
. then ( function ( data ) {
34
34
expect ( data ) . to . equal ( good ) ;
35
35
done ( ) ;
36
- } ) ;
36
+ } )
37
+ . catch ( done ) ;
37
38
} ) ;
38
39
39
40
it ( 'should do the right thing with bad requests' , function ( done ) {
40
- fetch ( 'https: //mattandre.ws/fail.txt' )
41
+ fetch ( '//mattandre.ws/fail.txt' )
41
42
. then ( responseToText )
42
43
. catch ( function ( err ) {
43
44
expect ( err . toString ( ) ) . to . equal ( "Error: Bad server response" ) ;
44
45
done ( ) ;
45
- } ) ;
46
+ } )
47
+ . catch ( done ) ;
46
48
} ) ;
47
49
48
50
} ) ;
You can’t perform that action at this time.
0 commit comments