Fix crash if articles contain urls with invalid host names

This commit is contained in:
benji7425 2017-12-03 15:53:12 +00:00
parent 96def786a4
commit 987473ffa6
2 changed files with 2 additions and 1 deletions

View File

@ -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

View File

@ -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);