Parcourir la source

Merge pull request #347 from fandyfyf/yff-swift-version

Update syntax to support both swift 3 and 4
Adam il y a 7 ans
Parent
commit
9c25524169
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      Sources/HttpParser.swift

+ 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