mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-14 04:17:29 +00:00
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.
This commit is contained in:
parent
f62fce4fea
commit
21629de594
@ -66,8 +66,15 @@ function rewriteVideoDescription(descriptionHtml, id) {
|
||||
// https://www.youtube.com/watch?v=fhum63fAwrI www.youtube.com/watch?v=<videoid>
|
||||
// https://www.youtube.com/watch?v=i-szWOrc3Mo www.youtube.com/<channelname> (unsupported by cloudtube currently)
|
||||
// https://www.youtube.com/watch?v=LSG71wbKpbQ www.youtube.com/channel/<id>
|
||||
// https://www.youtube.com/watch?v=RiEkOKFOG3s youtu.be/<videoid> with params
|
||||
|
||||
descriptionHtml = descriptionHtml.replace(new RegExp(`<a href="https?://(?:www\\.)?youtu\\.be/(${constants.regex.video_id})([^"]*)">([^<]+)</a>`, "g"), `<a href="/watch?v=$1$2">$3</a>`)
|
||||
descriptionHtml = descriptionHtml.replace(new RegExp(`<a href="https?://(?:www\\.)?youtu\\.be/(${constants.regex.video_id})[?]?([^"]*)">([^<]+)</a>`, "g"), (_, id, params, innerText) => {
|
||||
if (params) {
|
||||
return `<a href="/watch?v=${id}&${params}">${innerText}</a>`
|
||||
} else {
|
||||
return `<a href="/watch?v=${id}">${innerText}</a>`
|
||||
}
|
||||
})
|
||||
descriptionHtml = descriptionHtml.replace(new RegExp(`<a href="https?://(?:www\\.)?youtu(?:\\.be|be\\.com)/([^"]*)">([^<]+)<\/a>`, "g"), `<a href="/$1">$2</a>`)
|
||||
descriptionHtml = descriptionHtml.replace(new RegExp(`(?:([0-9]*):)?([0-5]?[0-9]):([0-5][0-9])`, "g"), (_, hours, minutes, seconds) => {
|
||||
let timeURL, timeDisplay, timeSeconds
|
||||
|
Loading…
Reference in New Issue
Block a user