Skip to content

Commit 4e6aa5c

Browse files
committed
fix exclude match failed
1 parent 75d3ac1 commit 4e6aa5c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class FetchMock {
7171
isExclude(url) {
7272
for (let i = 0; i < this.exclude.length; i++) {
7373
const excludeUrl = this.exclude[i];
74-
return excludeUrl === url || (excludeUrl instanceof RegExp && excludeUrl.exec(url) !== null);
74+
if (excludeUrl === url || (excludeUrl instanceof RegExp && excludeUrl.exec(url) !== null)) {
75+
return true;
76+
}
7577
}
7678
return false;
7779
}

test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import FetchMock, { Mock } from '../';
55
const fetch = new FetchMock(require('../__mocks__'), {
66
fetch: require('isomorphic-fetch'),
77
exclude: [
8-
'http://www.baidu.com',
98
/^foo(bar)?$/i,
9+
/http:\/\/www.baidu.com/,
1010
],
1111
}).fetch;
1212
describe('test fetch mock', () => {

0 commit comments

Comments
 (0)