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
URLwith ahostproperty 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) //> trueDeclaration
Swift
public static let missing: URLMatchable -
Wraps the given string to create a new
Hostvalue. It matchesURLs based on theirhostproperty.See also
Declaration
Swift
public init(_ host: String)Parameters
hostThe host to match. It will be compared for equality against
URL’shostproperty. -
Predicate that determines whether a
Hostmatches a givenURL.Declaration
Swift
public func matches(url: URL) -> BoolParameters
urlThe
URLto be matched.Return Value
trueif the wrapped host is equivalent tourl.host. Otherwise,false.
View on GitHub
Install in Dash
Host Structure Reference