Scheme
public struct Scheme : Equatable
Type that wraps a validated URL scheme, as per RFC 3986, §3.1.
The value
property of a Scheme
should be considered safe for use in contexts which require a valid scheme name, as any invalid scheme formulations would be rejected by the contructor.
-
Scheme format errors.
See moreDeclaration
Swift
public enum Format : LocalizedError
-
Scheme size errors.
See moreDeclaration
Swift
public enum Size : LocalizedError
-
Convienience for http scheme.
Declaration
Swift
public static let http: Scheme
-
Convienience for https scheme.
Declaration
Swift
public static let https: Scheme
-
Convienience for tel scheme.
Declaration
Swift
public static let tel: Scheme
-
Convienience for telPrompt scheme.
Declaration
Swift
public static let telprompt: Scheme
-
Convienience for sms scheme.
Declaration
Swift
public static let sms: Scheme
-
Convienience for mailto scheme.
Declaration
Swift
public static let mailto: Scheme
-
Convienience for webcal scheme.
Declaration
Swift
public static let webcal: Scheme
-
Convienience for file scheme.
Declaration
Swift
public static let file: Scheme
-
Convienience for ftp scheme.
Declaration
Swift
public static let ftp: Scheme
-
A validated scheme, as per RFC 3986, §3.1.
Declaration
Swift
public let value: String
-
Creates a
Scheme
value, which holds a validated URL scheme as per RFC 3986, §3.1 (orthrow
s trying).RFC 952 states “Scheme names consist of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus (
+
), period (.
), or hyphen (-
).” Any givenscheme
incosistent with these rules will cause the initializer tothrow
.Additionally, the RFC says “An implementation should accept uppercase letters as equivalent to lowercase in scheme names for the sake of robustness but should only produce lowercase scheme names for consistency.” For this reason, the given
scheme
islowercased
before validation and storage.Throws
Scheme.Format.invalidCharacter
ifscheme
contains invalid character.Scheme.Size.tooSmall
isscheme
is zero-length.Declaration
Swift
public init(_ scheme: String) throws
Parameters
scheme
The scheme to be validated. Will be stored
lowercased
. Will throw an error if invalid.
-
Undocumented
Declaration
Swift
public static var missing: URLMatchable { get }
-
Predicate that determines whether a
Scheme
matches a givenURL
.Declaration
Swift
public func matches(url: URL) -> Bool
Parameters
url
The
URL
to be matched.Return Value
true
ifScheme
’svalue
property is equal tourl.scheme
. Otherwise,false
.