The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update utils.ts
Steven Tey3ae555f8cef9
diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.tsindex f785cd7c67..34b32934be 100644--- a/lib/middleware/utils.ts+++ b/lib/middleware/utils.ts@@ -29,12 +29,12 @@ export const getFinalUrl = (target: string, { req }: { req: NextRequest }) => {// query is the query string (e.g. dub.sh/github?utm_source=twitter -> ?utm_source=twitter)const searchParams = req.nextUrl.searchParams;- // @ts-ignore – until https://github.com/microsoft/TypeScript/issues/54466 is fixed- if (searchParams.size === 0) return target; // if there are no query params, then return the target url as is (no need to parse it-// get the query params of the target urlconst targetUrl = new URL(decodeURIComponent(target));+ // @ts-ignore – until https://github.com/microsoft/TypeScript/issues/54466 is fixed+ if (searchParams.size === 0) return targetUrl; // if there are no query params, then return the target url as is (no need to parse it+// if searchParams (type: `URLSearchParams`) has the same key as target url, then overwrite itfor (const [key, value] of searchParams) {targetUrl.searchParams.set(key, value);