options.ts 866 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. export interface IOptions {
  2. allowIcannDomains: boolean;
  3. allowPrivateDomains: boolean;
  4. detectIp: boolean;
  5. extractHostname: boolean;
  6. mixedInputs: boolean;
  7. validHosts: string[] | null;
  8. validateHostname: boolean;
  9. }
  10. function setDefaultsImpl({
  11. allowIcannDomains = true,
  12. allowPrivateDomains = false,
  13. detectIp = true,
  14. extractHostname = true,
  15. mixedInputs = true,
  16. validHosts = null,
  17. validateHostname = true,
  18. }: Partial<IOptions>): IOptions {
  19. return {
  20. allowIcannDomains,
  21. allowPrivateDomains,
  22. detectIp,
  23. extractHostname,
  24. mixedInputs,
  25. validHosts,
  26. validateHostname,
  27. };
  28. }
  29. const DEFAULT_OPTIONS = /*@__INLINE__*/ setDefaultsImpl({});
  30. export function setDefaults(options?: Partial<IOptions>): IOptions {
  31. if (options === undefined) {
  32. return DEFAULT_OPTIONS;
  33. }
  34. return /*@__INLINE__*/ setDefaultsImpl(options);
  35. }