Extensions
The following extensions are available globally.
-
An extension of
See moreURLthat conforms to theTLDExtractableprotocol. This extension provides functionality to initialize aURLfrom a Unicode string and to extract the hostname from the URL.Declaration
Swift
extension URL: TLDExtractable -
An extension of
Stringthat conforms to theTLDExtractableprotocol. This extension provides functionality to extract the hostname from a string, which may represent a URL or a domain name.The
See morehostnameproperty 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.Declaration
Swift
extension String: TLDExtractableReturn Value
A string representing the hostname, or
nilif it cannot be extracted.
View on GitHub
Install in Dash
Extensions Reference