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
commit ebb2016915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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(),