rcgit

/ karakeep

Commit bc6ee2ed

SHA bc6ee2edc9f16791b2bb64049c2c34ed83796d29
Author MohamedBassem <me at mbassem dot com>
Author Date 2024-04-06 00:38 +0100
Committer MohamedBassem <me at mbassem dot com>
Commit Date 2024-04-06 00:38 +0100
Parent(s) a81c3941465e (diff)
Tree eb5b87cb4d93

patch snapshot

fix: Only consider text as URL in editor card if it has an http protocol. Fixes #86
File + - Graph
M apps/web/components/dashboard/bookmarks/EditorCard.tsx +4 -1
1 file(s) changed, 4 insertions(+), 1 deletions(-)

apps/web/components/dashboard/bookmarks/EditorCard.tsx

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