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 a port property of nil.

    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 matches URLs based on their port property.

    Declaration

    Swift

    public init(_ port: Int)

    Parameters

    port

    The port number to match. It will be compared for equality against URL’s port property.

  • Predicate that determines whether a Port matches a given URL.

    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 to url.port. Otherwise, false.