mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-13 22:26:28 +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;
|
export let number: number;
|
||||||
|
|
||||||
let imageLoaded = false;
|
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";
|
$: itemType = item.type ?? "photo";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="picker-item"
|
class="picker-item"
|
||||||
on:click={() =>
|
on:click={() => {
|
||||||
|
if (validUrl) {
|
||||||
downloadFile({
|
downloadFile({
|
||||||
url: item.url,
|
url: item.url,
|
||||||
urlType: isTunnel ? "tunnel" : "redirect",
|
urlType: isTunnel ? "tunnel" : "redirect",
|
||||||
})}
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div class="picker-type">
|
<div class="picker-type">
|
||||||
{#if itemType === "video"}
|
{#if itemType === "video"}
|
||||||
|
|
Loading…
Reference in a new issue