Merge pull request #3978 from sloped/fix/detect-http-https-upgrades

fix: allow upgrading HTTP to HTTPS for redirects
This commit is contained in:
advplyr 2025-02-18 17:18:36 -06:00 committed by GitHub
commit fd3d4f5fcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -343,6 +343,14 @@ module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => {
return payload.podcast
})
.catch((error) => {
// Check for failures due to redirecting from http to https. If original url was http, upgrade to https and try again
if (error.code === 'ERR_FR_REDIRECTION_FAILURE' && error.cause.code === 'ERR_INVALID_PROTOCOL') {
if (feedUrl.startsWith('http://') && error.request._options.protocol === 'https:') {
Logger.info('Redirection from http to https detected. Upgrading Request', error.request._options.href)
feedUrl = feedUrl.replace('http://', 'https://')
return this.getPodcastFeed(feedUrl, excludeEpisodeMetadata)
}
}
Logger.error('[podcastUtils] getPodcastFeed Error', error)
return null
})