File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ export default async function fetch(url, options_) {
168
168
}
169
169
170
170
default :
171
- // Do nothing
171
+ return reject ( new TypeError ( `Redirect option ' ${ request . redirect } ' is not a valid value of RequestRedirect` ) ) ;
172
172
}
173
173
}
174
174
Original file line number Diff line number Diff line change @@ -524,6 +524,19 @@ describe('node-fetch', () => {
524
524
} ) ;
525
525
} ) ;
526
526
527
+ it ( 'should throw a TypeError on an invalid redirect option' , ( ) => {
528
+ const url = `${ base } redirect/301` ;
529
+ const options = {
530
+ redirect : 'foobar'
531
+ } ;
532
+ return fetch ( url , options ) . then ( ( ) => {
533
+ expect . fail ( ) ;
534
+ } , error => {
535
+ expect ( error ) . to . be . an . instanceOf ( TypeError ) ;
536
+ expect ( error . message ) . to . equal ( 'Redirect option \'foobar\' is not a valid value of RequestRedirect' ) ;
537
+ } ) ;
538
+ } ) ;
539
+
527
540
it ( 'should set redirected property on response when redirect' , ( ) => {
528
541
const url = `${ base } redirect/301` ;
529
542
return fetch ( url ) . then ( res => {
You can’t perform that action at this time.
0 commit comments