fix(embed): standardize `instance` or `b` parameter

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2489>
environments/review-docs-2173-fg9d5z/deployments/18018
Kasper Seweryn 2023-06-22 00:34:52 +02:00 zatwierdzone przez Marge
rodzic 9cee08b264
commit c7e9152590
1 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -20,7 +20,7 @@
// Params
const params = new URL(location.href).searchParams
const baseUrl = params.get('instance') ?? params.get('b') ?? ''
let baseUrl = params.get('instance') ?? params.get('b') ?? location.origin
const type = params.get('type')
const id = params.get('id')
@ -34,6 +34,14 @@
error.value = `The embed widget couldn't read the provided media ID: ${id}.`
}
// Standardize base URL
try {
baseUrl = new URL(baseUrl).origin
} catch (err) {
console.error(err)
error.value = `The embed widget couldn't read the provided instance URL: ${baseUrl}.`
}
// Cover
const DEFAULT_COVER = '/embed-default-cover.jpeg'
const cover = reactive({ value: DEFAULT_COVER })