Skip to content

Commit

Permalink
fix(XbelSerializer): titles need their own <title> element
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Dec 9, 2023
1 parent 81a4fce commit 1ccff6a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib/serializers/Xbel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class XbelSerializer implements Serializer {
id: parseInt(node[':@']['@_id']),
parentId: folder.id,
url: node[':@']['@_href'],
title: node.bookmark?.[0]?.['#text'] || '',
title: node.bookmark?.[0]?.title?.['#text'] || '',
location: ItemLocation.SERVER,
})
} else if (typeof node.folder !== 'undefined') {
item = new Folder({
id: parseInt(node[':@']?.['@_id']),
title: node[':@']?.['@_title'] || '',
title: node.bookmark?.[0]?.title?.['#text'] || '',
parentId: folder.id,
location: ItemLocation.SERVER,
})
Expand All @@ -66,7 +66,7 @@ class XbelSerializer implements Serializer {
if (child instanceof Bookmark) {
return {
bookmark: [
{'#text': child.title}
{title: [{'#text': child.title}]}
],
':@': {
'@_href': child.url,
Expand All @@ -77,10 +77,12 @@ class XbelSerializer implements Serializer {

if (child instanceof Folder) {
return {
folder: this._serializeFolder(child),
folder: [
{title: [{'#text': child.title}]},
...this._serializeFolder(child)
],
':@': {
...('id' in child && {'@_id': String(child.id)}),
'@_title': child.title,
}
}
}
Expand Down

0 comments on commit 1ccff6a

Please sign in to comment.