Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

handle undefined

jlssmt102690fc10db
diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.ts
index 8056c111..c2105e3e 100644
--- a/lib/api/controllers/links/postLink.ts
+++ b/lib/api/controllers/links/postLink.ts
@@ -86,6 +86,8 @@ export default async function postLink(
else if (contentType === "image/png") imageExtension = "png";
}
+ if (!link.tags) link.tags = [];
+
const newLink = await prisma.link.create({
data: {
url: link.url?.trim().replace(/\/+$/, "") || null,
@@ -98,7 +100,7 @@ export default async function postLink(
},
},
tags: {
- connectOrCreate: link.tags.map((tag) => ({
+ connectOrCreate: link.tags?.map((tag) => ({
where: {
name_ownerId: {
name: tag.name.trim(),