From a5af174db51a09ce6750520d2fb2d5b6bf90323a Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Mon, 18 Sep 2017 00:53:11 +0900 Subject: filter closed path --- src/background/histories.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/background/histories.js') 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 -- cgit v1.2.3