module

ActionDispatch::Http::URL::DomainExtractor

DomainExtractor provides utility methods for extracting domain and subdomain information from host strings. This module is used internally by Action Dispatch to parse host names and separate the domain from subdomains based on the top-level domain (TLD) length.

The module assumes a standard domain structure where domains consist of:

  • Subdomains (optional, can be multiple levels)

  • Domain name

  • Top-level domain (TLD, can be multiple levels like .co.uk)

For example, in “api.staging.example.co.uk”:

  • Subdomains: [“api”, “staging”]

  • Domain: “example.co.uk” (with tld_length=2)

  • TLD: “co.uk”

Files

  • actionpack/lib/action_dispatch/http/url.rb