Skip to content

Commit 6c4ef48

Browse files
committed
fix(NextcloudBookmarks#getExistingBookmarks): Don't use search-by-url for javascript links
Signed-off-by: Marcel Klehr <[email protected]>
1 parent f63e61d commit 6c4ef48

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/lib/adapters/NextcloudBookmarks.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,28 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
586586
})
587587
}
588588

589-
/*
590-
* This is pretty expensive! We need to wait until NcBookmarks has support for
591-
* querying urls directly
592-
*/
593589
async getExistingBookmark(url:string):Promise<false|Bookmark> {
590+
if (url.toLowerCase().startsWith('javascript:')) {
591+
if (!this.hasFeatureJavascriptLinks) {
592+
return false
593+
}
594+
const json = await this.sendRequest(
595+
'GET',
596+
`index.php/apps/bookmarks/public/rest/v2/bookmark?page=-1&search[]=${encodeURIComponent(
597+
'javascript:'
598+
)}`
599+
)
600+
if (json.data.length) {
601+
const bookmark = json.data.find(bookmark => bookmark.target === url)
602+
if (bookmark) {
603+
return {...bookmark, parentId: bookmark.folders[0], url}
604+
} else {
605+
return false
606+
}
607+
} else {
608+
return false
609+
}
610+
}
594611
const json = await this.sendRequest(
595612
'GET',
596613
`index.php/apps/bookmarks/public/rest/v2/bookmark?url=${encodeURIComponent(

0 commit comments

Comments
 (0)