Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

make sure URL is not being pasted in an input or textarea

Steven Tey81f450df8f25
diff --git a/app/dub.sh/page.tsx b/app/dub.sh/page.tsx
index 3c14a93e05..7043f863c9 100644
--- a/app/dub.sh/page.tsx
+++ b/app/dub.sh/page.tsx
@@ -1,4 +1,3 @@
-import Background from "#/ui/home/background";
import Demo from "#/ui/home/demo";
import Globe from "#/ui/home/globe";
import Stats from "#/ui/home/stats";
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index e183c16dd0..508b117b13 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -605,7 +605,14 @@ function AddEditLinkButton({
// listen to paste event, and if it's a URL, open the modal and input the URL
const handlePaste = (e: ClipboardEvent) => {
const pastedContent = e.clipboardData?.getData("text");
- if (pastedContent && isValidUrl(pastedContent)) {
+ const target = e.target as HTMLElement;
+
+ // make sure it's a valid URL and is not being pasted in an input or textarea
+ if (
+ pastedContent &&
+ isValidUrl(pastedContent) &&
+ !(target.tagName === "INPUT" || target.tagName === "TEXTAREA")
+ ) {
setShowAddEditLinkModal(true);
}
};