소스 검색

Fixed content type validation issue where parameter parsing was incorrect.

Christian Noon 10 년 전
부모
커밋
63fce12f7a
2개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Source/Validation.swift
  2. 2 0
      Tests/ValidationTests.swift

+ 1 - 1
Source/Validation.swift

@@ -94,7 +94,7 @@ extension Request {
         init?(_ string: String) {
             let components: [String] = {
                 let stripped = string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
-                let split = stripped.substringToIndex(stripped.rangeOfString(";")?.endIndex ?? stripped.endIndex)
+                let split = stripped.substringToIndex(stripped.rangeOfString(";")?.startIndex ?? stripped.endIndex)
                 return split.componentsSeparatedByString("/")
             }()
 

+ 2 - 0
Tests/ValidationTests.swift

@@ -116,6 +116,8 @@ class ContentTypeValidationTestCase: BaseTestCase {
         // When
         Alamofire.request(.GET, URLString)
             .validate(contentType: ["application/json"])
+            .validate(contentType: ["application/json;charset=utf8"])
+            .validate(contentType: ["application/json;q=0.8;charset=utf8"])
             .response { _, _, _, responseError in
                 error = responseError
                 expectation.fulfill()