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.

Update destination-url-input.tsx

Steven Tey8107113f5d03
diff --git a/apps/web/ui/links/destination-url-input.tsx b/apps/web/ui/links/destination-url-input.tsx
index 2a98f1fb83..ab427dc45d 100644
--- a/apps/web/ui/links/destination-url-input.tsx
+++ b/apps/web/ui/links/destination-url-input.tsx
@@ -7,7 +7,7 @@ import {
useMediaQuery,
UTM_PARAMETERS,
} from "@dub/ui";
-import { getParamsFromURL } from "@dub/utils";
+import { getParamsFromURL, getUrlFromString } from "@dub/utils";
import { forwardRef, HTMLProps, ReactNode, useId } from "react";
import { useFormContext } from "react-hook-form";
import { AlertCircleFill } from "../shared/icons";
@@ -108,6 +108,13 @@ export const DestinationUrlInput = forwardRef<
);
},
})}
+ onBlur={(e) => {
+ const url = getUrlFromString(e.target.value);
+ if (url) {
+ // remove trailing slash and set the https:// prefix
+ formContext.setValue("url", url.replace(/\/$/, ""));
+ }
+ }}
/>
{error && (
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">