mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 04:42:56 +08:00
@@ -4,6 +4,14 @@ import { imageProxyBuilder } from './proxy';
|
|||||||
|
|
||||||
const localhost = new Set(['localhost', '127.0.0.1']);
|
const localhost = new Set(['localhost', '127.0.0.1']);
|
||||||
|
|
||||||
|
const URL_FIXERS: Record<string, (url: URL) => URL> = {
|
||||||
|
'open.spotify.com': (url: URL) => {
|
||||||
|
// with si query, spotify will redirect to landing page which [Open Desktop] check
|
||||||
|
url.searchParams.delete('si');
|
||||||
|
return url;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export function fixUrl(url?: string): URL | null {
|
export function fixUrl(url?: string): URL | null {
|
||||||
if (typeof url !== 'string') {
|
if (typeof url !== 'string') {
|
||||||
return null;
|
return null;
|
||||||
@@ -28,6 +36,12 @@ export function fixUrl(url?: string): URL | null {
|
|||||||
// check hostname is a valid domain
|
// check hostname is a valid domain
|
||||||
(fullDomain === parsed.hostname || localhost.has(parsed.hostname))
|
(fullDomain === parsed.hostname || localhost.has(parsed.hostname))
|
||||||
) {
|
) {
|
||||||
|
const fixer = URL_FIXERS[parsed.hostname];
|
||||||
|
|
||||||
|
if (fixer) {
|
||||||
|
return fixer(parsed);
|
||||||
|
}
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
Reference in New Issue
Block a user