Fix: wrong usage of URL.protocol, again

This commit is contained in:
John Livingston 2023-04-21 18:57:18 +02:00
parent 493c3dd25b
commit 5a4eb7fc33
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC

View File

@ -34,8 +34,8 @@ export function canonicalizePluginUri (
uri = new url.URL(path, options.peertubeHelpers.config.getWebserverUrl()) uri = new url.URL(path, options.peertubeHelpers.config.getWebserverUrl())
} }
if (canonicalizeOptions?.protocol) { if (canonicalizeOptions?.protocol) {
// Assuming that current protocol is https? or wss?, other cases dont concern us, and will be buggy // Assuming that current protocol is https?: or wss?:, other cases dont concern us, and will be buggy
const currentProtocolSecure = uri.protocol.endsWith('s:') const currentProtocolSecure = uri.protocol === 'https:' || uri.protocol === 'wss:'
if (canonicalizeOptions.protocol === 'http') { if (canonicalizeOptions.protocol === 'http') {
uri.protocol = currentProtocolSecure ? 'https' : 'http' uri.protocol = currentProtocolSecure ? 'https' : 'http'
} else if (canonicalizeOptions.protocol === 'ws') { } else if (canonicalizeOptions.protocol === 'ws') {