Merge pull request #671 from jlssmt/main

handle undefined
This commit is contained in:
Daniel
2024-08-14 17:40:28 -04:00
committed by GitHub
+3 -1
View File
@@ -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(),