From 4db50c234fb0da8747b902a7c1e551cc54451f4c Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Thu, 26 Sep 2024 21:01:00 +0000 Subject: fix(web): Don't parse empty tags in netscape imports. Fixes #421 --- apps/web/lib/importBookmarkParser.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apps/web/lib/importBookmarkParser.ts') diff --git a/apps/web/lib/importBookmarkParser.ts b/apps/web/lib/importBookmarkParser.ts index e1b21a79..1f80e5f4 100644 --- a/apps/web/lib/importBookmarkParser.ts +++ b/apps/web/lib/importBookmarkParser.ts @@ -24,15 +24,17 @@ export async function parseNetscapeBookmarkFile( const $a = $(a); const addDate = $a.attr("add_date"); let tags: string[] = []; + + const tagsStr = $a.attr("tags"); try { - tags = $a.attr("tags")?.split(",") ?? []; + tags = tagsStr && tagsStr.length > 0 ? tagsStr.split(",") : []; } catch (e) { /* empty */ } return { title: $a.text(), url: $a.attr("href"), - tags: tags, + tags, addDate: typeof addDate === "undefined" ? undefined : parseInt(addDate), }; }) @@ -60,7 +62,7 @@ export async function parsePocketBookmarkFile( return { title: $a.text(), url: $a.attr("href"), - tags: tags, + tags, addDate: typeof addDate === "undefined" ? undefined : parseInt(addDate), }; }) -- cgit v1.2.3-70-g09d2