From 21629de5947e4da4d2962ce3f0c16b1a7c447e21 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Mon, 28 Jun 2021 01:04:38 +0200 Subject: [PATCH] Properly rewrite URL params for youtu.be links Change occurs in converters.rewriteVideoDescription(). Previously the URL could end up with `?` in it twice, this ensures there will be at most one. --- utils/converters.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/converters.js b/utils/converters.js index 6e17567..d723cda 100644 --- a/utils/converters.js +++ b/utils/converters.js @@ -66,8 +66,15 @@ function rewriteVideoDescription(descriptionHtml, id) { // https://www.youtube.com/watch?v=fhum63fAwrI www.youtube.com/watch?v= // https://www.youtube.com/watch?v=i-szWOrc3Mo www.youtube.com/ (unsupported by cloudtube currently) // https://www.youtube.com/watch?v=LSG71wbKpbQ www.youtube.com/channel/ + // https://www.youtube.com/watch?v=RiEkOKFOG3s youtu.be/ with params - descriptionHtml = descriptionHtml.replace(new RegExp(`([^<]+)`, "g"), `$3`) + descriptionHtml = descriptionHtml.replace(new RegExp(`([^<]+)`, "g"), (_, id, params, innerText) => { + if (params) { + return `${innerText}` + } else { + return `${innerText}` + } + }) descriptionHtml = descriptionHtml.replace(new RegExp(`([^<]+)<\/a>`, "g"), `$2`) descriptionHtml = descriptionHtml.replace(new RegExp(`(?:([0-9]*):)?([0-5]?[0-9]):([0-5][0-9])`, "g"), (_, hours, minutes, seconds) => { let timeURL, timeDisplay, timeSeconds