From cc5e74e46eee32a06a61239d6c7a1ff8d784b6f5 Mon Sep 17 00:00:00 2001 From: benji7425 Date: Sun, 3 Dec 2017 15:53:12 +0000 Subject: [PATCH] Fix crash if articles contain urls with invalid host names --- CHANGELOG.md | 1 + app/models/feed-data.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51f2a7e..68f64f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased ### Fixed +- Fix bot crash if feed article contains link with invalid host name - Temporary fix for bot crash if used with a feed without links in the articles (didn't realise this was possible...) ## v3.1.3 diff --git a/app/models/feed-data.js b/app/models/feed-data.js index 26e3fc6..4fc5c18 100644 --- a/app/models/feed-data.js +++ b/app/models/feed-data.js @@ -107,7 +107,7 @@ function normaliseUrl(url) { url = url.replace("https://", "http://"); //hacky way to treat http and https the same const parsedUrl = Url.parse(url); - if (parsedUrl.host.includes("youtube.com")) { + if (parsedUrl.host && parsedUrl.host.includes("youtube.com")) { const videoIDParam = (parsedUrl.query || "").split("&").find(x => x.startsWith("v=")); if (videoIDParam) { const videoID = videoIDParam.substring(videoIDParam.indexOf("=") + 1, videoIDParam.length);