Host
public struct Host : URLMatchable
Type that matches a URL
based on comparison with the URL
’s host
propery.
Usage:
let url = URL(string: "https://example.com")!
Host("example.com").matches(url) //> true
Host(".com").matches(url) //> false
See also
HostSuffix
-
A value that matches a
URL
with ahost
property ofnil
.Usage:
let host = URL(string: "http://example.com")! let noHost = URL(string: "http://")! Host.missing.matches(url: host) //> false Host.missing.matches(url: noHost) //> true
Declaration
Swift
public static let missing: URLMatchable
-
Wraps the given string to create a new
Host
value. It matchesURL
s based on theirhost
property.See also
Declaration
Swift
public init(_ host: String)
Parameters
host
The host to match. It will be compared for equality against
URL
’shost
property. -
Predicate that determines whether a
Host
matches a givenURL
.Declaration
Swift
public func matches(url: URL) -> Bool
Parameters
url
The
URL
to be matched.Return Value
true
if the wrapped host is equivalent tourl.host
. Otherwise,false
.