Skip to content

Commit 4a915cc

Browse files
committed
feat(HtmlSerializer): Use auto-inc IDs as a fallback when parsing
for items that don't have an ID Signed-off-by: Marcel Klehr <[email protected]>
1 parent 9b7eec4 commit 4a915cc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lib/serializers/Html.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ export const parseByString = (content: string) => {
8181
const body = $('body')
8282
const root: TItem<typeof ItemLocation.SERVER>[] = []
8383
const rdt = getRootFolder(body).children('dt')
84+
let idCounter = 1
8485

8586
const parseNode = (node: cheerio.Cheerio<any>, parentId?: string|number) => {
8687
const eq0 = node.children().eq(0)
8788
const title = typeof eq0.text() !== 'undefined' ? eq0.text() : ''
8889
let url = ''
89-
const id = typeof eq0.attr('id') !== 'undefined' ? eq0.attr('id') : ''
90+
const id = typeof eq0.attr('id') !== 'undefined' ? eq0.attr('id') : idCounter++
9091
let children: TItem<typeof ItemLocation.SERVER>[] = []
9192

9293
switch (eq0[0].name) {

0 commit comments

Comments
 (0)