forked from SukkaW/Surge
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SukkaW:master' into master
- Loading branch information
Showing
18 changed files
with
94 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import { TTL, fsFetchCache } from './lib/cache-filesystem'; | ||
import { defaultRequestInit, fetchWithRetry } from './lib/fetch-retry'; | ||
import { createMemoizedPromise } from './lib/memo-promise'; | ||
import { traceAsync } from './lib/trace-runner'; | ||
|
||
export const getPublicSuffixListTextPromise = createMemoizedPromise(() => traceAsync( | ||
'obtain public_suffix_list', | ||
() => fsFetchCache.apply( | ||
'https://publicsuffix.org/list/public_suffix_list.dat', | ||
() => fetchWithRetry('https://publicsuffix.org/list/public_suffix_list.dat', defaultRequestInit).then(r => r.text()), | ||
{ | ||
// https://github.com/publicsuffix/list/blob/master/.github/workflows/tld-update.yml | ||
// Though the action runs every 24 hours, the IANA list is updated every 7 days. | ||
// So a 3 day TTL should be enough. | ||
ttl: TTL.THREE_DAYS() | ||
} | ||
) | ||
export const getPublicSuffixListTextPromise = createMemoizedPromise(() => fsFetchCache.apply( | ||
'https://publicsuffix.org/list/public_suffix_list.dat', | ||
() => fetchWithRetry('https://publicsuffix.org/list/public_suffix_list.dat', defaultRequestInit).then(r => r.text()), | ||
{ | ||
// https://github.com/publicsuffix/list/blob/master/.github/workflows/tld-update.yml | ||
// Though the action runs every 24 hours, the IANA list is updated every 7 days. | ||
// So a 3 day TTL should be enough. | ||
ttl: TTL.THREE_DAYS() | ||
} | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { createCache } from './cache-apply'; | ||
import type { PublicSuffixList } from '@gorhill/publicsuffixlist'; | ||
|
||
let gothillGetDomainCache: ReturnType<typeof createCache> | null = null; | ||
let gorhillGetDomainCache: ReturnType<typeof createCache> | null = null; | ||
export const createCachedGorhillGetDomain = (gorhill: PublicSuffixList) => { | ||
gothillGetDomainCache ??= createCache('cached-gorhill-get-domain', true); | ||
return (domain: string) => { | ||
// we do know gothillGetDomainCache exists here | ||
return gothillGetDomainCache!.sync(domain, () => gorhill.getDomain(domain[0] === '.' ? domain.slice(1) : domain)); | ||
}; | ||
gorhillGetDomainCache ??= createCache('cached-gorhill-get-domain', true); | ||
return (domain: string) => gorhillGetDomainCache! // we do know gothillGetDomainCache exists here | ||
.sync(domain, () => gorhill.getDomain(domain[0] === '.' ? domain.slice(1) : domain)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.