From 74030b26c534417b90a3e647bea5b1d1c37dc2e2 Mon Sep 17 00:00:00 2001 From: LeonKohli <98176333+LeonKohli@users.noreply.github.com> Date: Wed, 8 May 2024 21:00:12 +0200 Subject: [PATCH] Fix bookmark import issue with missing folder names --- .../migration/importFromHTMLFile.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/api/controllers/migration/importFromHTMLFile.ts b/lib/api/controllers/migration/importFromHTMLFile.ts index 21fb3c4..745ee05 100644 --- a/lib/api/controllers/migration/importFromHTMLFile.ts +++ b/lib/api/controllers/migration/importFromHTMLFile.ts @@ -63,11 +63,21 @@ async function processBookmarks( ) as Element; if (collectionName) { - collectionId = await createCollection( - userId, - (collectionName.children[0] as TextNode).content, - parentCollectionId - ); + const collectionNameContent = (collectionName.children[0] as TextNode)?.content; + if (collectionNameContent) { + collectionId = await createCollection( + userId, + collectionNameContent, + parentCollectionId + ); + } else { + // Handle the case when the collection name is empty + collectionId = await createCollection( + userId, + "Untitled Collection", + parentCollectionId + ); + } } await processBookmarks( userId, @@ -264,3 +274,4 @@ function processNodes(nodes: Node[]) { nodes.forEach(findAndProcessDL); return nodes; } +