Skip to content

Commit 15e47cc

Browse files
committed
Fix getPublicUrl to handle relative and absolute URLs
1 parent cd613e2 commit 15e47cc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ function getUrlObject(req) {
119119
*/
120120
export function getPublicUrl(publicUrl, req) {
121121
if (publicUrl) {
122-
return publicUrl;
122+
try {
123+
return new URL(publicUrl).toString();
124+
} catch {
125+
return new URL(publicUrl, getUrlObject(req)).toString();
126+
}
123127
}
124128
return getUrlObject(req).toString();
125129
}

0 commit comments

Comments
 (0)