Skip to content

Commit

Permalink
Protect against malformed URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Feb 26, 2016
1 parent 3068483 commit a11a915
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 3 deletions.
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ function isBadgeUrl(url) {
}

module.exports = readme => {
return getUrls(
readme.split('http').map(url => 'http' + url).join(' ') // Separate urls by spaces first
)
let urls;

readme = readme || readme.split('http').map(url => 'http' + url).join(' '); // Separate urls by spaces first

try {
urls = getUrls(readme);
} catch (err) {
return [];
}

return urls
.map(url => url && url.split(')')[0]) // ignore markdown syntax leftovers
.filter(url => !!url && isBadgeUrl(url))
.map(url => {
Expand Down

0 comments on commit a11a915

Please sign in to comment.