aboutsummaryrefslogtreecommitdiff
path: root/src/background/histories.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-17 23:03:34 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-17 23:03:34 +0900
commitf8e7e7840a96d6b09b60aa41469df9ed7de02933 (patch)
treee8b9ee76ab8895a792714ed43d86c722a3719378 /src/background/histories.js
parent4bd55b67b6c71a1f80305f942ddfbc7a9df142f3 (diff)
drop http history if https if in histories
Diffstat (limited to 'src/background/histories.js')
-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]);
});
};