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.

fix dub-no-track removal

Steven Tey99ce8d9a74c3
diff --git a/apps/web/lib/middleware/utils/get-final-url.ts b/apps/web/lib/middleware/utils/get-final-url.ts
index 4267fa32a2..37b071b366 100644
--- a/apps/web/lib/middleware/utils/get-final-url.ts
+++ b/apps/web/lib/middleware/utils/get-final-url.ts
@@ -10,12 +10,9 @@ export const getFinalUrl = (
// get the query params of the target url
const urlObj = new URL(url);
- // remove dub-no-track param from the final url if it exists (used to skip tracking)
- if (urlObj.searchParams.has("dub-no-track")) {
- urlObj.searchParams.delete("dub-no-track");
- // if there's no dub-no-track param, then add clickId to the final url if it exists
- // reasoning: if you're skipping tracking, there's no point in passing the clickId anyway
- } else if (clickId) {
+ // if there's no dub-no-track search param, then add clickId to the final url if it exists
+ // reasoning: if you're skipping tracking, there's no point in passing the clickId anyway
+ if (!searchParams.has("dub-no-track") && clickId) {
// add clickId to the final url if it exists
urlObj.searchParams.set("dub_id", clickId);
}
@@ -26,7 +23,10 @@ export const getFinalUrl = (
// if searchParams (type: `URLSearchParams`) has the same key as target url, then overwrite it
for (const [key, value] of searchParams) {
- urlObj.searchParams.set(key, value);
+ // we will pass everything except dub-no-track (used for skipping tracking)
+ if (key !== "dub-no-track") {
+ urlObj.searchParams.set(key, value);
+ }
}
// remove qr param from the final url if the value is "1" (only used for detectQr function)