Skip to content

Commit

Permalink
fix(HtmlSerializer): Try to fix ordering test
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Dec 10, 2023
1 parent 1073786 commit 729f6d2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib/serializers/Html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class HtmlSerializer implements Serializer {
.map(child => {
if (child instanceof Bookmark) {
return (
`${indent}<DT>` +
`<A HREF="${child.url}" TAGS="${''}" ID="${child.id}">${child.title}</A>\n`
`${indent}<DT><A HREF="${child.url}" TAGS="${''}" ID="${child.id}">${child.title}</A>\n`
)
} else if (child instanceof Folder) {
const nextIndent = indent + ' '
Expand All @@ -30,9 +29,9 @@ class HtmlSerializer implements Serializer {
}

deserialize(html): Folder {
const folders: Folder[] = parseByString(html)
folders.forEach(f => {f.parentId = '0'})
return new Folder({id: '0', title: 'root', children: folders, location: ItemLocation.SERVER, isRoot: true})
const items: TItem[] = parseByString(html)
items.forEach(f => { f.parentId = '0' })
return new Folder({id: '0', title: 'root', children: items, location: ItemLocation.SERVER, isRoot: true})
}
}

Expand Down Expand Up @@ -78,7 +77,7 @@ export const parseByString = (content: string) => {
})

const body = $('body')
const root: Folder[] = []
const root: TItem[] = []
const rdt = getRootFolder(body).children('dt')

const parseNode = (node: cheerio.Cheerio<cheerio.Element>, parentId?: string|number) => {
Expand Down Expand Up @@ -110,7 +109,7 @@ export const parseByString = (content: string) => {

rdt.each((_, item) => {
const node = $(item)
const child = parseNode(node) as Folder
const child = parseNode(node)
root.push(child)
})

Expand Down

0 comments on commit 729f6d2

Please sign in to comment.