download-publicsuffixlist.ts 855 B

1234567891011121314151617181920
  1. import { TTL, fsCache } from './lib/cache-filesystem';
  2. import { defaultRequestInit, fetchWithRetry } from './lib/fetch-retry';
  3. import { createMemoizedPromise } from './lib/memo-promise';
  4. import { traceAsync } from './lib/trace-runner';
  5. export const getPublicSuffixListTextPromise = createMemoizedPromise(
  6. () => traceAsync(
  7. 'obtain public_suffix_list',
  8. () => fsCache.apply(
  9. 'https://publicsuffix.org/list/public_suffix_list.dat',
  10. () => fetchWithRetry('https://publicsuffix.org/list/public_suffix_list.dat', defaultRequestInit).then(r => r.text()),
  11. {
  12. // https://github.com/publicsuffix/list/blob/master/.github/workflows/tld-update.yml
  13. // Though the action runs every 24 hours, the IANA list is updated every 7 days.
  14. // So a 3 day TTL should be enough.
  15. ttl: TTL.THREE_DAYS()
  16. }
  17. )
  18. )
  19. );