module

ActionDispatch::Http::URL::DomainExtractor

rails latest stable

Module not available on this version

This module is only available on newer versions. The first available version (v8.1.1) is shown here.

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