From d3c855a9bc80b44d574b419be9ddd32b6c2cb51c Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Thu, 9 Jun 2016 12:24:22 -0400 Subject: [PATCH] updating URI model --- Sources/URI.swift | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/Sources/URI.swift b/Sources/URI.swift index 68a2768..3c14201 100644 --- a/Sources/URI.swift +++ b/Sources/URI.swift @@ -1,3 +1,37 @@ +/* + https://tools.ietf.org/html/rfc3986#section-1 + + 3. Syntax Components + + The generic URI syntax consists of a hierarchical sequence of + components referred to as the scheme, authority, path, query, and + fragment. + + URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] + + hier-part = "//" authority path-abempty + / path-absolute + / path-rootless + / path-empty + + The scheme and path components are required, though the path may be + empty (no characters). When authority is present, the path must + either be empty or begin with a slash ("/") character. When + authority is not present, the path cannot begin with two slash + characters ("//"). These restrictions result in five different ABNF + rules for a path (Section 3.3), only one of which will match any + given URI reference. + + The following are two example URIs and their component parts: + + foo://example.com:8042/over/there?name=ferret#nose + \_/ \______________/\_________/ \_________/ \__/ + | | | | | + scheme authority path query fragment + | _____________________|__ + / \ / \ + urn:example:animal:ferret:nose + */ public struct URI { public struct UserInfo { public var username: String @@ -14,10 +48,16 @@ public struct URI { public var host: String? public var port: Int? public var path: String? - public var query: [String: [String?]] + public var query: String? public var fragment: String? - public init(scheme: String? = nil, userInfo: UserInfo? = nil, host: String? = nil, port: Int? = nil, path: String? = nil, query: [String: [String?]] = [:], fragment: String? = nil) { + public init(scheme: String? = nil, + userInfo: UserInfo? = nil, + host: String? = nil, + port: Int? = nil, + path: String? = nil, + query: String? = nil, + fragment: String? = nil) { self.scheme = scheme self.userInfo = userInfo self.host = host