download-publicsuffixlist.ts 712 B

123456789101112131415
  1. import { deserializeArray, fsFetchCache, getFileContentHash, serializeArray } from './cache-filesystem';
  2. import { createMemoizedPromise } from './memo-promise';
  3. export const getPublicSuffixListTextPromise = createMemoizedPromise(() => fsFetchCache.applyWithHttp304<string[]>(
  4. 'https://publicsuffix.org/list/public_suffix_list.dat',
  5. getFileContentHash(__filename),
  6. (r) => r.text().then(text => text.split('\n')),
  7. {
  8. // https://github.com/publicsuffix/list/blob/master/.github/workflows/tld-update.yml
  9. // Though the action runs every 24 hours, the IANA list is updated every 7 days.
  10. // So a 3 day TTL should be enough.
  11. serializer: serializeArray,
  12. deserializer: deserializeArray
  13. }
  14. ));