! Fix thumbnail URL for protocol-relative URLs (#3452)

This commit is contained in:
PikachuEXE 2023-04-26 07:12:40 +08:00 committed by GitHub
parent db1e88ae16
commit a3c4981ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -162,16 +162,20 @@ export default defineComponent({
thumbnailURL: function(originalURL) {
let newURL = originalURL
const hostname = new URL(originalURL).hostname
// Sometimes relative protocol URLs are passed in
if (originalURL.startsWith('//')) {
newURL = `https:${originalURL}`
}
const hostname = new URL(newURL).hostname
if (hostname === 'yt3.ggpht.com' || hostname === 'yt3.googleusercontent.com') {
if (this.backendPreference === 'invidious') { // YT to IV
newURL = youtubeImageUrlToInvidious(originalURL, this.currentInvidiousInstance)
newURL = youtubeImageUrlToInvidious(newURL, this.currentInvidiousInstance)
}
} else {
if (this.backendPreference === 'local') { // IV to YT
newURL = originalURL.replace(this.re.ivToYt, `${this.ytBaseURL}/$1`)
newURL = newURL.replace(this.re.ivToYt, `${this.ytBaseURL}/$1`)
} else { // IV to IV
newURL = invidiousImageUrlToInvidious(originalURL, this.currentInvidiousInstance)
newURL = invidiousImageUrlToInvidious(newURL, this.currentInvidiousInstance)
}
}