diff options
Diffstat (limited to 'src/background/usecases/filters.ts')
-rw-r--r-- | src/background/usecases/filters.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/background/usecases/filters.ts b/src/background/usecases/filters.ts index 84a42fb..98957a7 100644 --- a/src/background/usecases/filters.ts +++ b/src/background/usecases/filters.ts @@ -1,13 +1,13 @@ type Item = browser.history.HistoryItem; const filterHttp = (items: Item[]): Item[] => { - let httpsHosts = items.map(x => new URL(x.url as string)) + const httpsHosts = items.map(x => new URL(x.url as string)) .filter(x => x.protocol === 'https:') .map(x => x.host); - let hostsSet = new Set(httpsHosts); + const hostsSet = new Set(httpsHosts); return items.filter((item: Item) => { - let url = new URL(item.url as string); + const url = new URL(item.url as string); return url.protocol === 'https:' || !hostsSet.has(url.host); }); }; @@ -17,14 +17,14 @@ const filterBlankTitle = (items: Item[]): Item[] => { }; const filterByTailingSlash = (items: Item[]): Item[] => { - let urls = items.map(item => new URL(item.url as string)); - let simplePaths = urls + const urls = items.map(item => new URL(item.url as string)); + const simplePaths = urls .filter(url => url.hash === '' && url.search === '') .map(url => url.origin + url.pathname); - let pathsSet = new Set(simplePaths); + const pathsSet = new Set(simplePaths); return items.filter((item) => { - let url = new URL(item.url as string); + const url = new URL(item.url as string); if (url.hash !== '' || url.search !== '' || url.pathname.slice(-1) !== '/') { return true; @@ -34,10 +34,10 @@ const filterByTailingSlash = (items: Item[]): Item[] => { }; const filterByPathname = (items: Item[], min: number): Item[] => { - let hash: {[key: string]: Item} = {}; - for (let item of items) { - let url = new URL(item.url as string); - let pathname = url.origin + url.pathname; + const hash: {[key: string]: Item} = {}; + for (const item of items) { + const url = new URL(item.url as string); + const pathname = url.origin + url.pathname; if (!hash[pathname]) { hash[pathname] = item; } else if ((hash[pathname].url as string).length > @@ -45,7 +45,7 @@ const filterByPathname = (items: Item[], min: number): Item[] => { hash[pathname] = item; } } - let filtered = Object.values(hash); + const filtered = Object.values(hash); if (filtered.length < min) { return items; } @@ -53,9 +53,9 @@ const filterByPathname = (items: Item[], min: number): Item[] => { }; const filterByOrigin = (items: Item[], min: number): Item[] => { - let hash: {[key: string]: Item} = {}; - for (let item of items) { - let origin = new URL(item.url as string).origin; + const hash: {[key: string]: Item} = {}; + for (const item of items) { + const origin = new URL(item.url as string).origin; if (!hash[origin]) { hash[origin] = item; } else if ((hash[origin].url as string).length > @@ -63,7 +63,7 @@ const filterByOrigin = (items: Item[], min: number): Item[] => { hash[origin] = item; } } - let filtered = Object.values(hash); + const filtered = Object.values(hash); if (filtered.length < min) { return items; } |