Skip to content

Commit 28e618c

Browse files
committed
fix exclude match failed
1 parent 60c6d35 commit 28e618c

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-fetch-mock",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "fetch mock for react-native",
55
"main": "index.js",
66
"scripts": {

src/index.js

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

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)