aboutsummaryrefslogtreecommitdiff
path: root/src/background/histories.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/histories.js')
-rw-r--r--src/background/histories.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/background/histories.js b/src/background/histories.js
index d70cf57..6b6e4c6 100644
--- a/src/background/histories.js
+++ b/src/background/histories.js
@@ -12,6 +12,21 @@ const filterEmptyTitle = (items) => {
return items.filter(item => item[0].title && item[0].title !== '');
};
+const filterClosedPath = (items) => {
+ const allSimplePaths = items
+ .filter(item => item[1].hash === '' && item[1].search === '')
+ .map(item => item[1].origin + item[1].pathname);
+ const allSimplePathSet = new Set(allSimplePaths);
+ return items.filter(
+ item => !(item[1].hash === '' && item[1].search === '' &&
+ (/\/$/).test(item[1].pathname) &&
+ allSimplePathSet.has(
+ (item[1].origin + item[1].pathname).replace(/\/$/, '')
+ )
+ )
+ );
+};
+
const reduceByPathname = (items, min) => {
let hash = {};
for (let item of items) {
@@ -54,6 +69,7 @@ const getCompletions = (keyword) => {
return [historyItems.map(item => [item, new URL(item.url)])]
.map(filterEmptyTitle)
.map(filterHttp)
+ .map(filterClosedPath)
.map(items => reduceByPathname(items, 10))
.map(items => reduceByOrigin(items, 10))
.map(items => items