diff --git a/src/index.js b/src/index.js index 4b47a5e..e327a47 100644 --- a/src/index.js +++ b/src/index.js @@ -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; } }; diff --git a/test/index.test.js b/test/index.test.js index 49f4fe1..0000fdf 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -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( `