Fix https stream proxies
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
const APP_BASE_PATH = import.meta.env.BASE_URL ?? '/';
|
||||
|
||||
/** Returns whether a hostname belongs to Dropbox domains that often need proxy support. */
|
||||
function isDropboxHost(hostname: string): boolean {
|
||||
const host = hostname.toLowerCase();
|
||||
return host.endsWith('dropbox.com') || host.endsWith('dropboxusercontent.com');
|
||||
}
|
||||
|
||||
/** Returns whether the URL already points at the local media proxy. */
|
||||
function isLocalMediaProxyUrl(parsed: URL): boolean {
|
||||
return parsed.origin === window.location.origin && parsed.pathname.toLowerCase().endsWith('/media_proxy.php');
|
||||
@@ -15,15 +9,12 @@ function isLocalMediaProxyUrl(parsed: URL): boolean {
|
||||
export function shouldProxyRadioStreamUrl(streamUrl: string): boolean {
|
||||
try {
|
||||
const parsed = new URL(streamUrl);
|
||||
if (isLocalMediaProxyUrl(parsed)) {
|
||||
return false;
|
||||
}
|
||||
if (parsed.protocol === 'http:') return true;
|
||||
if (parsed.protocol === 'https:' && isDropboxHost(parsed.hostname)) return true;
|
||||
if (isLocalMediaProxyUrl(parsed)) return false;
|
||||
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false;
|
||||
return parsed.origin !== window.location.origin;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns whether an arbitrary external media URL should be proxied before Web Audio playback. */
|
||||
|
||||
@@ -112,11 +112,6 @@ function connectRadioChannelSource(
|
||||
}
|
||||
|
||||
/** Returns whether a hostname belongs to Dropbox domains that need proxy support. */
|
||||
function isDropboxHost(hostname: string): boolean {
|
||||
const host = hostname.toLowerCase();
|
||||
return host.endsWith('dropbox.com') || host.endsWith('dropboxusercontent.com');
|
||||
}
|
||||
|
||||
export function shouldProxyStreamUrl(streamUrl: string): boolean {
|
||||
try {
|
||||
const parsed = new URL(streamUrl);
|
||||
@@ -126,12 +121,11 @@ export function shouldProxyStreamUrl(streamUrl: string): boolean {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (parsed.protocol === 'http:') return true;
|
||||
if (parsed.protocol === 'https:' && isDropboxHost(parsed.hostname)) return true;
|
||||
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false;
|
||||
return parsed.origin !== window.location.origin;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getProxyUrlForStream(streamUrl: string): string {
|
||||
|
||||
Reference in New Issue
Block a user