Skip to content

Commit

Permalink
Do not throw an exception when URI parsing fails
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Aug 14, 2017
1 parent 28e32dc commit 514062f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/js/libs/handlebars/ircmessageparser/findLinks.js
Expand Up @@ -23,8 +23,15 @@ function findLinks(text) {
// See https://medialize.github.io/URI.js/docs.html#static-withinString
// In our case, we store each URI encountered in a result array.
URI.withinString(text, function(url, start, end) {
// Extract the scheme of the URL detected, if there is one
const parsedScheme = URI(url).scheme().toLowerCase();
let parsedScheme;

try {
// Extract the scheme of the URL detected, if there is one
parsedScheme = URI(url).scheme().toLowerCase();
}
catch (e) {
return;
}

// Check if the scheme of the detected URL matches a common one above.
// In a URL like `foo..http://example.com`, the scheme would be `foo..http`,
Expand Down

0 comments on commit 514062f

Please sign in to comment.