Skip to content

Commit

Permalink
Protect againt empty file (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
piecioshka committed May 25, 2019
1 parent 222cb03 commit 9802251
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Expand Up @@ -8,7 +8,9 @@ module.exports = {

const result = [];
const docs = text.match(GOOGLE_DOCS_REGEXP);
result.push(...docs);
if (docs) {
result.push(...docs);
}
return result;
}
};
11 changes: 11 additions & 0 deletions test/index.test.js
Expand Up @@ -19,6 +19,17 @@ it('should inform that non-string is passed', () => {
}).toThrowError();
});

it('should return empty collection when string not contain matched url', () => {
const input = find(
`
Wlazł kotek na płotek
`
);
const output = [];

expect(input).toEqual(output);
});

it('should find one link', () => {
const input = find(
`
Expand Down

0 comments on commit 9802251

Please sign in to comment.