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 route.ts

Tim Wilson1fd365a3328d
diff --git a/apps/web/app/api/cron/import/csv/route.ts b/apps/web/app/api/cron/import/csv/route.ts
index bf4c80bddd..f252abea57 100644
--- a/apps/web/app/api/cron/import/csv/route.ts
+++ b/apps/web/app/api/cron/import/csv/route.ts
@@ -27,6 +27,10 @@ export async function POST(req: Request) {
if (!id || !url) throw new Error("Missing ID or URL for the import file");
const map = (row: Record<string, string>) => {
+ const createdAt = mapping.createdAt
+ ? new Date(row[mapping.createdAt])
+ : undefined;
+
return {
...Object.fromEntries(
Object.entries(mapping).map(([key, value]) => [key, row[value]]),
@@ -37,9 +41,8 @@ export async function POST(req: Request) {
?.replace(/^https?:\/\//, "")
.split("/")
.at(-1) ?? "",
- createdAt: mapping.createdAt
- ? new Date(row[mapping.createdAt])
- : undefined,
+ createdAt:
+ createdAt && !isNaN(createdAt.getTime()) ? createdAt : undefined,
tags: mapping.tags
? row[mapping.tags]?.split(",").map((tag) => tag.trim())
: undefined,