Extensions

The following extensions are available globally.

  • URL

    An extension of URL that conforms to the TLDExtractable protocol. This extension provides functionality to initialize a URL from a Unicode string and to extract the hostname from the URL.

    See more

    Declaration

    Swift

    extension URL: TLDExtractable
  • An extension of String that conforms to the TLDExtractable protocol. This extension provides functionality to extract the hostname from a string, which may represent a URL or a domain name.

    The hostname property uses regular expressions to identify and extract the hostname from the string. It checks for the presence of a scheme (e.g., http://) and handles both URLs and plain domain names.

    See more

    Declaration

    Swift

    extension String: TLDExtractable

    Return Value

    A string representing the hostname, or nil if it cannot be extracted.