diff options
| author | MohamedBassem <me@mbassem.com> | 2024-04-06 00:38:39 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-04-06 00:38:39 +0100 |
| commit | bc6ee2edc9f16791b2bb64049c2c34ed83796d29 (patch) | |
| tree | eb5b87cb4d93b852740058b7a4bceb21eb9e265a /apps/web/components/dashboard | |
| parent | a81c3941465e4fe650049e2557b9d5bbc67d47a8 (diff) | |
| download | karakeep-bc6ee2edc9f16791b2bb64049c2c34ed83796d29.tar.zst | |
fix: Only consider text as URL in editor card if it has an http protocol. Fixes #86
Diffstat (limited to 'apps/web/components/dashboard')
| -rw-r--r-- | apps/web/components/dashboard/bookmarks/EditorCard.tsx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/web/components/dashboard/bookmarks/EditorCard.tsx b/apps/web/components/dashboard/bookmarks/EditorCard.tsx index 28686e6c..6858255a 100644 --- a/apps/web/components/dashboard/bookmarks/EditorCard.tsx +++ b/apps/web/components/dashboard/bookmarks/EditorCard.tsx @@ -67,7 +67,10 @@ export default function EditorCard({ className }: { className?: string }) { const onSubmit: SubmitHandler<z.infer<typeof formSchema>> = (data) => { const text = data.text.trim(); try { - new URL(text); + const url = new URL(text); + if (url.protocol != "http:" && url.protocol != "https:") { + throw new Error("Invalid URL"); + } mutate({ type: "link", url: text }); } catch (e) { // Not a URL |
