diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-12-22 11:10:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-22 11:10:36 +0900 |
commit | b1a6f374dca078dee2406ebe049715b826e37ca2 (patch) | |
tree | 5367c48648e2018f55f12d847baba94559e10040 /src/background/usecases/filters.ts | |
parent | b2dcdedad729ff7087867da50e20578f9fc8fb29 (diff) | |
parent | da72c2ddd916d79d134662e3985b53a4ac78af7a (diff) |
Merge pull request #690 from ueokande/eslint-and-prettier
Eslint and prettier
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; } |