Fix (actually this time) youtube feature urls not being properly converted
This commit is contained in:
parent
691af2761f
commit
e447c1c07f
|
@ -80,10 +80,14 @@ module.exports = class FeedData {
|
|||
function normaliseUrl(url) {
|
||||
url = url.replace("https://", "http://"); //hacky way to treat http and https the same
|
||||
|
||||
if (Url.parse(url).host.startsWith("http://youtu"))
|
||||
url = url.split("?")[0]; //quick way to chop off stuff like ?feature=youtube
|
||||
|
||||
url = url.replace(/(www.)?youtube.com\/watch\?v=/, "youtu.be/"); //convert youtube full url to short
|
||||
const parsedUrl = Url.parse(url);
|
||||
if (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);
|
||||
url = "http://youtu.be/" + videoID;
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
Loading…
Reference in a new issue