Fix getPublicUrl to handle relative and absolute URLs

This commit is contained in:
Monnte 2025-03-11 14:22:58 +01:00
parent 3110cab18f
commit 396768da7b

View file

@ -119,7 +119,11 @@ function getUrlObject(req) {
*/ */
export function getPublicUrl(publicUrl, req) { export function getPublicUrl(publicUrl, req) {
if (publicUrl) { if (publicUrl) {
return publicUrl; try {
return new URL(publicUrl).toString();
} catch {
return new URL(publicUrl, getUrlObject(req)).toString();
}
} }
return getUrlObject(req).toString(); return getUrlObject(req).toString();
} }