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