host(percentEncoded:)

Returns the host component of the URL if present, otherwise returns nil.

iOS
16.0+
macOS
13.0+
tvOS
16.0+
watchOS
9.0+
func host(percentEncoded: Bool = true) -> String?

Parameters

percentEncoded

Whether the host should be percent encoded, defaults to true.

Returns

The host component of the URL