Skip to content

Commit

Permalink
fix(web): Don't parse empty tags in netscape imports. Fixes #421
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Sep 26, 2024
1 parent 12d3371 commit 4db50c2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/web/lib/importBookmarkParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
})
Expand Down Expand Up @@ -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),
};
})
Expand Down

0 comments on commit 4db50c2

Please sign in to comment.