Skip to content

Commit

Permalink
fix(NextcloudBookmarks#getExistingBookmarks): Don't use search-by-url…
Browse files Browse the repository at this point in the history
… for javascript links

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed May 17, 2024
1 parent f63e61d commit 3b10afe
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/lib/adapters/NextcloudBookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,28 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
})
}

/*
* This is pretty expensive! We need to wait until NcBookmarks has support for
* querying urls directly
*/
async getExistingBookmark(url:string):Promise<false|Bookmark> {
if (url.toLowerCase().startsWith('javascript:')) {
if (!this.hasFeatureJavascriptLinks) {
return false
}
const json = await this.sendRequest(
'GET',
`index.php/apps/bookmarks/public/rest/v2/bookmark?limit=0&search[]=${encodeURIComponent(
'javascript:'
)}`
)
if (json.data.length) {
const bookmark = json.data.find(bookmark => bookmark.target === url)
if (bookmark) {
return {...bookmark, parentId: bookmark.folders[0], url}
} else {
return false
}
} else {
return false
}
}
const json = await this.sendRequest(
'GET',
`index.php/apps/bookmarks/public/rest/v2/bookmark?url=${encodeURIComponent(
Expand Down

0 comments on commit 3b10afe

Please sign in to comment.