isSubdomainOf static method

bool isSubdomainOf(
  1. Uri potentialSub,
  2. Uri root, {
  3. bool icann = false,
})

Checks if a URL is a subdomain of another.

Both URLs are parsed to PublicSuffix objects, which are then compared using PublicSuffix.isSubdomainOf().

Throws a StateError if SuffixRules has not been initialised.

Implementation

static bool isSubdomainOf(Uri potentialSub, Uri root, {bool icann = false}) {
  var parsedUrl = PublicSuffix(url: potentialSub);
  var parsedRoot = PublicSuffix(url: root);

  return parsedUrl.isSubdomainOf(parsedRoot, icann: icann);
}