# isFQDN method

bool isFQDN([

1. Map<String, Object>? options

])

Check if the string is a fully qualified domain name (e.g. domain.com).

`options` is a `Map` which defaults to `{ 'require_tld': true, 'allow_underscores': false }`.

## Implementation

    bool isFQDN([Map<String, Object>? options]) {
      var str = this;

      final defaultFqdnOptions = {'require_tld': true, 'allow_underscores': false};

      options = options?.merge(defaultFqdnOptions) ?? defaultFqdnOptions;
      final parts = str.split('.');
      if (options['require_tld'] as bool) {
        var tld = parts.removeLast();
        if (parts.isEmpty || !RegExp(r'^[a-z]{2,}$').hasMatch(tld)) {
          return false;
        }
      }

      for (final part in parts) {
        if (options['allow_underscores'] as bool) {
          if (part.contains('__')) {
            return false;
          }
        }
        if (!RegExp(r'^[a-z\\u00a1-\\uffff0-9-]+$').hasMatch(part)) {
          return false;
        }
        if (part[0] == '-' ||
            part[part.length - 1] == '-' ||
            part.contains('---')) {
          return false;
        }
      }
      return true;
    }