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