diff options
| author | MohamedBassem <me@mbassem.com> | 2024-09-26 21:01:00 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-09-26 21:01:00 +0000 |
| commit | 4db50c234fb0da8747b902a7c1e551cc54451f4c (patch) | |
| tree | 956458a8654ebe59ad9a472b72c8357bd6f53945 /apps/web/lib/importBookmarkParser.ts | |
| parent | 12d3371d12d5709adc6e23b53792cf1dc28a8a06 (diff) | |
| download | karakeep-4db50c234fb0da8747b902a7c1e551cc54451f4c.tar.zst | |
fix(web): Don't parse empty tags in netscape imports. Fixes #421
Diffstat (limited to '')
| -rw-r--r-- | apps/web/lib/importBookmarkParser.ts | 8 |
1 files changed, 5 insertions, 3 deletions
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), }; }) |
