diff options
Diffstat (limited to 'src/background/completion/BookmarkRepository.ts')
-rw-r--r-- | src/background/completion/BookmarkRepository.ts | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/background/completion/BookmarkRepository.ts b/src/background/completion/BookmarkRepository.ts index 12f5455..14105c8 100644 --- a/src/background/completion/BookmarkRepository.ts +++ b/src/background/completion/BookmarkRepository.ts @@ -1,32 +1,8 @@ -import { injectable } from "tsyringe"; - export type BookmarkItem = { title: string url: string } -const COMPLETION_ITEM_LIMIT = 10; - -@injectable() -export default class BookmarkRepository { - async queryBookmarks(query: string): Promise<BookmarkItem[]> { - const items = await browser.bookmarks.search({ query }); - return items - .filter(item => item.title && item.title.length > 0) - .filter(item => item.type === 'bookmark' && item.url) - .filter((item) => { - let url = undefined; - try { - url = new URL(item.url!!); - } catch (e) { - return false; - } - return url.protocol !== 'place:'; - }) - .slice(0, COMPLETION_ITEM_LIMIT) - .map(item => ({ - title: item.title!!, - url: item.url!!, - })); - } +export default interface BookmarkRepository { + queryBookmarks(query: string): Promise<BookmarkItem[]>; } |