Skip to content

Commit

Permalink
Ignore invalid URLs
Browse files Browse the repository at this point in the history
The `url-regex` package might sometimes detect invalid URLs and it would throw. This just ignores such errors.

Closes #39
  • Loading branch information
sindresorhus committed Dec 18, 2018
1 parent 82685ae commit d3d0f29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ module.exports = (text, options = {}) => {
const ret = new Set();

const add = url => {
ret.add(normalizeUrl(url.trim().replace(/\.+$/, ''), options));
try {
ret.add(normalizeUrl(url.trim().replace(/\.+$/, ''), options));
} catch (_) {}
};

const urls = text.match(urlRegex()) || [];
Expand Down

0 comments on commit d3d0f29

Please sign in to comment.