mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-13 14:16:25 +01:00
web/PickerItem: make sure the item url is valid
This commit is contained in:
parent
366279a3bc
commit
f76d40bec4
1 changed files with 16 additions and 6 deletions
|
@ -14,18 +14,28 @@
|
|||
export let number: number;
|
||||
|
||||
let imageLoaded = false;
|
||||
const isTunnel = new URL(item.url).pathname === "/tunnel";
|
||||
|
||||
let validUrl = false;
|
||||
try {
|
||||
new URL(item.url);
|
||||
validUrl = true;
|
||||
} catch {}
|
||||
|
||||
const isTunnel = validUrl && new URL(item.url).pathname === "/tunnel";
|
||||
|
||||
$: itemType = item.type ?? "photo";
|
||||
</script>
|
||||
|
||||
<button
|
||||
class="picker-item"
|
||||
on:click={() =>
|
||||
downloadFile({
|
||||
url: item.url,
|
||||
urlType: isTunnel ? "tunnel" : "redirect",
|
||||
})}
|
||||
on:click={() => {
|
||||
if (validUrl) {
|
||||
downloadFile({
|
||||
url: item.url,
|
||||
urlType: isTunnel ? "tunnel" : "redirect",
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div class="picker-type">
|
||||
{#if itemType === "video"}
|
||||
|
|
Loading…
Reference in a new issue