Browse Source

Update syntax to support all swift versions

yifanfu 7 years ago
parent
commit
8baefd9071
3 changed files with 5 additions and 0 deletions
  1. BIN
      .DS_Store
  2. 5 0
      Sources/HttpParser.swift
  3. BIN
      XCode/.DS_Store

BIN
.DS_Store


+ 5 - 0
Sources/HttpParser.swift

@@ -39,7 +39,12 @@ public class HttpParser {
         let queryStart = url.index(after: questionMark)
         let queryStart = url.index(after: questionMark)
 
 
         guard url.endIndex > queryStart else { return [] }
         guard url.endIndex > queryStart else { return [] }
+
+        #if swift(>=4.0)
         let query = String(url[queryStart..<url.endIndex])
         let query = String(url[queryStart..<url.endIndex])
+        #else
+        guard let query = String(url[queryStart..<url.endIndex]) else { return [] }
+        #endif
 
 
         return query.components(separatedBy: "&")
         return query.components(separatedBy: "&")
             .reduce([(String, String)]()) { (c, s) -> [(String, String)] in
             .reduce([(String, String)]()) { (c, s) -> [(String, String)] in

BIN
XCode/.DS_Store