diff --git a/Source/ParameterEncoding.swift b/Source/ParameterEncoding.swift index 76e43180e..ac1c1baf2 100644 --- a/Source/ParameterEncoding.swift +++ b/Source/ParameterEncoding.swift @@ -223,9 +223,9 @@ public struct URLEncoding: ParameterEncoding { let endIndex = string.index(index, offsetBy: batchSize, limitedBy: string.endIndex) ?? string.endIndex let range = startIndex..<endIndex - let substring = string.substring(with: range) + let substring = string[range] - escaped += substring.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) ?? substring + escaped += substring.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet) ?? String(substring) index = endIndex } diff --git a/Source/Request.swift b/Source/Request.swift index 0e2382775..90caa6899 100644 --- a/Source/Request.swift +++ b/Source/Request.swift @@ -309,7 +309,11 @@ extension Request: CustomDebugStringConvertible { let cookies = cookieStorage.cookies(for: url), !cookies.isEmpty { let string = cookies.reduce("") { $0 + "\($1.name)=\($1.value);" } + #if swift(>=3.2) + components.append("-b \"\(string[..<string.index(before: string.endIndex)])\"") + #else components.append("-b \"\(string.substring(to: string.characters.index(before: string.endIndex)))\"") + #endif } } diff --git a/Source/Validation.swift b/Source/Validation.swift index c405d02af..3dde41738 100644 --- a/Source/Validation.swift +++ b/Source/Validation.swift @@ -48,7 +48,11 @@ extension Request { init?(_ string: String) { let components: [String] = { let stripped = string.trimmingCharacters(in: .whitespacesAndNewlines) + #if swift(>=3.2) + let split = stripped[..<(stripped.range(of: ";")?.lowerBound ?? stripped.endIndex)] + #else let split = stripped.substring(to: stripped.range(of: ";")?.lowerBound ?? stripped.endIndex) + #endif return split.components(separatedBy: "/") }()