String

extension String: 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.

Return Value

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

  • Undocumented

    Declaration

    Swift

    public var hostname: String? { get }