aboutsummaryrefslogtreecommitdiff
path: root/src/background/shared/completions/bookmarks.js
blob: 1adb35094149c36b4a23c5cb59c7ea02f470a8b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const getCompletions = (keywords) => {
  return browser.bookmarks.search({ query: keywords }).then((items) => {
    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 };