Extensions
The following extensions are available globally.
-
An extension of
See moreURL
that conforms to theTLDExtractable
protocol. This extension provides functionality to initialize aURL
from a Unicode string and to extract the hostname from the URL.Declaration
Swift
extension URL: TLDExtractable
-
An extension of
String
that conforms to theTLDExtractable
protocol. This extension provides functionality to extract the hostname from a string, which may represent a URL or a domain name.The
See morehostname
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.Declaration
Swift
extension String: TLDExtractable
Return Value
A string representing the hostname, or
nil
if it cannot be extracted.