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.

fixed edge cases

Steven Tey24a3650d4d4e
diff --git a/app/ui/modals/add-edit-link-modal/index.tsx b/app/ui/modals/add-edit-link-modal/index.tsx
index c862ca9c1e..730032dead 100644
--- a/app/ui/modals/add-edit-link-modal/index.tsx
+++ b/app/ui/modals/add-edit-link-modal/index.tsx
@@ -193,7 +193,7 @@ function AddEditLinkModal({
return {
method: "PUT",
url: `/api/links/${encodeURIComponent(props.key)}${
- slug ? `?slug=${slug}&domain=${domain}` : ""
+ slug ? `?slug=${slug}&domain=${props.domain}` : ""
}`,
};
} else {
diff --git a/lib/api/links.ts b/lib/api/links.ts
index 359f5a046f..fe78595649 100644
--- a/lib/api/links.ts
+++ b/lib/api/links.ts
@@ -6,55 +6,6 @@ import { redis } from "@/lib/upstash";
import { getParamsFromURL, isReservedKey, nanoid, truncate } from "@/lib/utils";
import { NextApiRequest } from "next";
-const getFiltersFromStatus = (status: string) => {
- if (status === "all" || status === "none") {
- return {
- archived: undefined,
- expiresAt: undefined,
- };
- }
- const selectedStatus = status.split(",");
- const activeSelected = selectedStatus.includes("active");
- const expiredSelected = selectedStatus.includes("expired");
- const archivedSelected = selectedStatus.includes("archived");
- return {
- AND: [
- {
- // archived can be either true or false
- archived:
- archivedSelected && selectedStatus.length === 1
- ? true
- : !archivedSelected
- ? false
- : undefined,
- },
- {
- OR: [
- {
- /* expiresAt can be either:
- - null
- - a date that's in the past
- - a date that's in the future
- */
- expiresAt:
- expiredSelected && !activeSelected
- ? { lt: new Date() }
- : activeSelected && !expiredSelected
- ? { gte: new Date() }
- : undefined,
- },
- {
- expiresAt: activeSelected && !expiredSelected ? null : undefined,
- },
- {
- archived: archivedSelected && !activeSelected ? true : undefined,
- },
- ],
- },
- ],
- };
-};
-
export async function getLinksForProject({
projectId,
domain,
diff --git a/pages/api/links/[key]/index.ts b/pages/api/links/[key]/index.ts
index 34be3190fa..185462948b 100644
--- a/pages/api/links/[key]/index.ts
+++ b/pages/api/links/[key]/index.ts
@@ -51,7 +51,7 @@ export default withLinksAuth(
userId: session.user.id,
},
{
- oldDomain,
+ oldDomain: oldDomain || "dub.sh",
oldKey,
},
),