aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/background/histories.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/background/histories.js b/src/background/histories.js
index b276a2d..4adada7 100644
--- a/src/background/histories.js
+++ b/src/background/histories.js
@@ -1,9 +1,22 @@
+const filterHttp = (items) => {
+ const httpsHosts = items
+ .filter(item => item[1].protocol === 'https:')
+ .map(item => item[1].host);
+ const httpsHostSet = new Set(httpsHosts);
+ return items.filter(
+ item => !(item[1].protocol === 'http:' && httpsHostSet.has(item[1].host))
+ );
+};
+
const getCompletions = (keyword) => {
return browser.history.search({
text: keyword,
startTime: '1970-01-01'
}).then((items) => {
- return items.sort((x, y) => x.lastVisitTime < y.lastVisitTime).slice(0, 10);
+ return filterHttp(items.map(item => [item, new URL(item.url)]))
+ .sort((x, y) => x[0].lastVisitTime < y[0].lastVisitTime)
+ .slice(0, 10)
+ .map(item => item[0]);
});
};