diff --git a/src/components/media.jsx b/src/components/media.jsx index ce2f13ac..727bcb06 100644 --- a/src/components/media.jsx +++ b/src/components/media.jsx @@ -166,7 +166,7 @@ function Media({ [to], ); - const remoteMediaURLObj = remoteMediaURL ? new URL(remoteMediaURL) : null; + const remoteMediaURLObj = remoteMediaURL ? getURLObj(remoteMediaURL) : null; const isVideoMaybe = type === 'unknown' && remoteMediaURLObj && @@ -618,4 +618,13 @@ function Media({ } } +function getURLObj(url) { + try { + // Fake base URL if url doesn't have https:// prefix + return new URL(url, location.origin); + } catch (e) { + return null; + } +} + export default Media;