mirror of
https://github.com/0x2E/fusion.git
synced 2026-05-19 18:30:35 +00:00
Fix Safari iOS URL.parse compatibility issue causing TypeError when opening news articles (#188)
* Initial plan * Initial exploration of issue #186 - Safari iOS URL.parse compatibility Co-authored-by: 0x2E <29594728+0x2E@users.noreply.github.com> * Fix Safari iOS URL.parse compatibility issue #186 Co-authored-by: 0x2E <29594728+0x2E@users.noreply.github.com> * Remove frontend/package-lock.json from PR as requested Co-authored-by: 0x2E <29594728+0x2E@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: 0x2E <29594728+0x2E@users.noreply.github.com>
This commit is contained in:
@@ -23,13 +23,18 @@ export function debounce(func: Function, wait: number): EventListener {
|
||||
export function tryAbsURL(url: string, base?: string): string {
|
||||
if (!url) return url;
|
||||
|
||||
let parsed = URL.parse(url, base);
|
||||
if (!parsed) {
|
||||
try {
|
||||
const parsed = new URL(url, base);
|
||||
return parsed.href;
|
||||
} catch {
|
||||
if (url.startsWith('//')) {
|
||||
url = 'https:' + url;
|
||||
try {
|
||||
const parsed = new URL('https:' + url, base);
|
||||
return parsed.href;
|
||||
} catch {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
parsed = URL.parse(url, base);
|
||||
return url;
|
||||
}
|
||||
|
||||
return parsed?.href || url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user