Skip to content

Commit

Permalink
Merge pull request #45 from open-swift/update-uri
Browse files Browse the repository at this point in the history
updating URI model
  • Loading branch information
tanner0101 authored Jun 10, 2016
2 parents 281a363 + d3c855a commit 743e79c
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions Sources/URI.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 743e79c

Please sign in to comment.