|
|
|
@ -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 |
|
|
|
|