From c4be1d3a37b0deb6b6087ec7a815262ac942daf1 Mon Sep 17 00:00:00 2001 From: jj Date: Wed, 30 Oct 2024 13:17:38 +0000 Subject: [PATCH] web/download: don't try to open non-https links --- web/src/lib/download.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/src/lib/download.ts b/web/src/lib/download.ts index 9cfbf630..7a126a92 100644 --- a/web/src/lib/download.ts +++ b/web/src/lib/download.ts @@ -56,6 +56,10 @@ export const shareFile = async (file: File) => { } export const openURL = (url: string) => { + if (!['http:', 'https:'].includes(new URL(url).protocol)) { + return alert('error: invalid url!'); + } + const open = window.open(url, "_blank"); /* if new tab got blocked by user agent, show a saving dialog */