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 more

    Declaration

    Swift

    public enum Format : LocalizedError
  • Scheme size errors.

    See more

    Declaration

    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
  • tel

    Convienience for tel scheme.

    Declaration

    Swift

    public static let tel: Scheme
  • Convienience for telPrompt scheme.

    Declaration

    Swift

    public static let telprompt: Scheme
  • sms

    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
  • ftp

    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 (or throws 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 given scheme incosistent with these rules will cause the initializer to throw.

    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 is lowercased before validation and storage.

    Throws

    Scheme.Format.invalidCharacter if scheme contains invalid character.

    Scheme.Size.tooSmall is scheme 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 given URL.

    Declaration

    Swift

    public func matches(url: URL) -> Bool

    Parameters

    url

    The URL to be matched.

    Return Value

    true if Scheme’s value property is equal to url.scheme. Otherwise, false.