mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-31 11:01:53 +08:00
Minor changes to previous build downloading
This commit is contained in:
14
Build/lib/download-publicsuffixlist.ts
Normal file
14
Build/lib/download-publicsuffixlist.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { TTL, fsFetchCache } from './cache-filesystem';
|
||||
import { defaultRequestInit, fetchWithRetry } from './fetch-retry';
|
||||
import { createMemoizedPromise } from './memo-promise';
|
||||
|
||||
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()
|
||||
}
|
||||
));
|
||||
@@ -1,6 +1,6 @@
|
||||
import { toASCII } from 'punycode';
|
||||
import { createMemoizedPromise } from './memo-promise';
|
||||
import { getPublicSuffixListTextPromise } from '../download-publicsuffixlist';
|
||||
import { getPublicSuffixListTextPromise } from './download-publicsuffixlist';
|
||||
|
||||
const customFetch = (url: string | URL): Promise<Blob> => Promise.resolve(Bun.file(url));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user