mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-26 03:05:41 +03:00
Fix crash when media url doesn't have http prefix
This commit is contained in:
parent
b0a53b7fa1
commit
62f843b4dc
1 changed files with 10 additions and 1 deletions
|
@ -166,7 +166,7 @@ function Media({
|
||||||
[to],
|
[to],
|
||||||
);
|
);
|
||||||
|
|
||||||
const remoteMediaURLObj = remoteMediaURL ? new URL(remoteMediaURL) : null;
|
const remoteMediaURLObj = remoteMediaURL ? getURLObj(remoteMediaURL) : null;
|
||||||
const isVideoMaybe =
|
const isVideoMaybe =
|
||||||
type === 'unknown' &&
|
type === 'unknown' &&
|
||||||
remoteMediaURLObj &&
|
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;
|
export default Media;
|
||||||
|
|
Loading…
Reference in a new issue