filter closed path
This commit is contained in:
parent
44d9123bc4
commit
a5af174db5
1 changed files with 16 additions and 0 deletions
|
@ -12,6 +12,21 @@ const filterEmptyTitle = (items) => {
|
||||||
return items.filter(item => item[0].title && item[0].title !== '');
|
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) => {
|
const reduceByPathname = (items, min) => {
|
||||||
let hash = {};
|
let hash = {};
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
|
@ -54,6 +69,7 @@ const getCompletions = (keyword) => {
|
||||||
return [historyItems.map(item => [item, new URL(item.url)])]
|
return [historyItems.map(item => [item, new URL(item.url)])]
|
||||||
.map(filterEmptyTitle)
|
.map(filterEmptyTitle)
|
||||||
.map(filterHttp)
|
.map(filterHttp)
|
||||||
|
.map(filterClosedPath)
|
||||||
.map(items => reduceByPathname(items, 10))
|
.map(items => reduceByPathname(items, 10))
|
||||||
.map(items => reduceByOrigin(items, 10))
|
.map(items => reduceByOrigin(items, 10))
|
||||||
.map(items => items
|
.map(items => items
|
||||||
|
|
Reference in a new issue