aboutsummaryrefslogtreecommitdiff
path: root/src/background/shared/completions/bookmarks.js
blob: bd753afc6f9e06d29d6c79888eb1c32b42971018 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const getCompletions = async(keywords) => {
  let items = await browser.bookmarks.search({ query: keywords });
  return items.filter((item) => {
    let url = undefined;
    try {
      url = new URL(item.url);
    } catch (e) {
      return false;
    }
    return item.type === 'bookmark' && url.protocol !== 'place:';
  }).slice(0, 10);
};

export { getCompletions };