added iOS source code
[wl-app.git] / iOS / Pods / OAuthSwift / Sources / URL+OAuthSwift.swift
diff --git a/iOS/Pods/OAuthSwift/Sources/URL+OAuthSwift.swift b/iOS/Pods/OAuthSwift/Sources/URL+OAuthSwift.swift
new file mode 100755 (executable)
index 0000000..e963754
--- /dev/null
@@ -0,0 +1,29 @@
+//
+//  URL+OAuthSwift.swift
+//  OAuthSwift
+//
+//  Created by Dongri Jin on 6/21/14.
+//  Copyright (c) 2014 Dongri Jin. All rights reserved.
+//
+
+import Foundation
+
+extension URL {
+
+    func urlByAppending(queryString: String) -> URL {
+        if queryString.utf16.isEmpty {
+            return self
+        }
+
+        var absoluteURLString = absoluteString
+
+        if absoluteURLString.hasSuffix("?") {
+            absoluteURLString.dropLast()
+        }
+
+        let string = absoluteURLString + (absoluteURLString.range(of: "?") != nil ? "&" : "?") + queryString
+
+        return URL(string: string)!
+    }
+
+}