loose-tldts-opt.ts 773 B

12345678910111213141516171819202122
  1. import type * as tldts from 'tldts';
  2. export const looseTldtsOpt: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
  3. allowPrivateDomains: false,
  4. extractHostname: false,
  5. mixedInputs: false,
  6. validateHostname: false,
  7. detectIp: false
  8. };
  9. export const loosTldOptWithPrivateDomains: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
  10. ...looseTldtsOpt,
  11. allowPrivateDomains: true
  12. };
  13. export const normalizeTldtsOpt: NonNullable<Parameters<typeof tldts.getSubdomain>[1]> = {
  14. allowPrivateDomains: true,
  15. // in normalizeDomain, we only care if it contains IP, we don't care if we need to extract it
  16. // by setting detectIp to false and manually check ip outside tldts.parse, we can skip the tldts
  17. // inner "extractHostname" call
  18. detectIp: false
  19. };