The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
small tweaks
Steven Teyc5e388ed8ef7
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsxindex 83d199573e..50f6a35e48 100644--- a/components/app/modals/add-edit-link-modal/index.tsx+++ b/components/app/modals/add-edit-link-modal/index.tsx@@ -31,16 +31,6 @@ import PasswordSection from "./password-section";import UTMSection from "./utm-section";import Preview from "./preview";-function process(data: LinkProps) {- const { ogEnabled, ...rest } = data;- return {- ...rest,- title: ogEnabled ? rest.title : null,- description: ogEnabled ? rest.description : null,- image: ogEnabled ? rest.image : null,- };-}-function AddEditLinkModal({showAddEditLinkModal,setShowAddEditLinkModal,@@ -87,7 +77,7 @@ function AddEditLinkModal({ogEnabled: false,},);- const { key, url, password, title, description, image, ogEnabled } = data;+ const { key, url, password, ogEnabled } = data;const [debouncedKey] = useDebounce(key, 500);useEffect(() => {@@ -294,12 +284,18 @@ function AddEditLinkModal({onSubmit={async (e) => {e.preventDefault();setSaving(true);+ const { ogEnabled, ...rest } = data;fetch(endpoint.url, {method: endpoint.method,headers: {"Content-Type": "application/json",},- body: JSON.stringify(process(data)),+ body: JSON.stringify({+ ...rest,+ title: ogEnabled ? rest.title : null,+ description: ogEnabled ? rest.description : null,+ image: ogEnabled ? rest.image : null,+ }),}).then((res) => {setSaving(false);if (res.status === 200) {diff --git a/components/app/modals/add-edit-link-modal/utm-section.tsx b/components/app/modals/add-edit-link-modal/utm-section.tsxindex a6e8e8074f..5bf7d794d3 100644--- a/components/app/modals/add-edit-link-modal/utm-section.tsx+++ b/components/app/modals/add-edit-link-modal/utm-section.tsx@@ -48,8 +48,17 @@ export default function UTMSection({url: props?.url || url,}));} else {- // if disabling, remove all params- setData((prev) => ({ ...prev, url: prev.url.split("?")[0] }));+ // if disabling, remove all UTM params+ let newURL;+ try {+ newURL = new URL(url);+ paramsMetadata.forEach((param) =>+ newURL.searchParams.delete(param.key),+ );+ setData((prev) => ({ ...prev, url: newURL.toString() }));+ } catch (e) {+ setData((prev) => ({ ...prev, url }));+ }}}, [enabled]);