kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
fix(embed): fix crash when API returns relative URL
Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2493>environments/review-docs-merge-hoc7bt/deployments/18064
rodzic
1e3c8081b5
commit
58d48a061e
|
@ -0,0 +1 @@
|
|||
Fixed embedded player crash when API returns relative listen URL. (#2163)
|
|
@ -73,7 +73,13 @@
|
|||
// NOTE: Add a transcoded MP3 src at the end for browsers
|
||||
// that do not support other codecs to be able to play it :)
|
||||
if (sources.length > 0 && !sources.some(({ mimetype }) => mimetype === 'audio/mpeg')) {
|
||||
const url = new URL(sources[0].listen_url)
|
||||
const source = sources[0].listen_url
|
||||
const url = new URL(source.test(/^https?:/)
|
||||
? source
|
||||
: source[0] === '/'
|
||||
? `${baseUrl}${source}`
|
||||
: `${baseUrl}/${source}`
|
||||
)
|
||||
url.searchParams.set('to', 'mp3')
|
||||
sources.push({ mimetype: 'audio/mpeg', listen_url: url.toString() })
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue