Commits

dcutting committed fd84ba5

Support uppercase HTTP schemes.

Comments (0)

Files changed (5)

VeriJSON.xcodeproj/project.pbxproj

 		C8A69A70169206370038211F /* ObjectWithBoolAsNumber.json in Resources */ = {isa = PBXBuildFile; fileRef = C8A69A6F169206370038211F /* ObjectWithBoolAsNumber.json */; };
 		C8CEF67E1694DD4D0098937F /* LICENSE.txt in Resources */ = {isa = PBXBuildFile; fileRef = C8CEF67C1694DD4D0098937F /* LICENSE.txt */; };
 		C8CEF67F1694DD4D0098937F /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = C8CEF67D1694DD4D0098937F /* README.md */; };
+		C8D2C99E1695DEE10020C5F6 /* ObjectWithHTTPURLUppercaseScheme.json in Resources */ = {isa = PBXBuildFile; fileRef = C8D2C99D1695DEE10020C5F6 /* ObjectWithHTTPURLUppercaseScheme.json */; };
+		C8D2C9A11695DF010020C5F6 /* ObjectWithHTTPSURLUppercaseScheme.json in Resources */ = {isa = PBXBuildFile; fileRef = C8D2C9A01695DF010020C5F6 /* ObjectWithHTTPSURLUppercaseScheme.json */; };
 		C8E11E151691D69600C36062 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8E11E141691D69600C36062 /* UIKit.framework */; };
 		C8E11E171691D69600C36062 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8E11E161691D69600C36062 /* Foundation.framework */; };
 		C8E11E191691D69600C36062 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8E11E181691D69600C36062 /* CoreGraphics.framework */; };
 		C8A69A6F169206370038211F /* ObjectWithBoolAsNumber.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = ObjectWithBoolAsNumber.json; path = Data/ObjectWithBoolAsNumber.json; sourceTree = "<group>"; };
 		C8CEF67C1694DD4D0098937F /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
 		C8CEF67D1694DD4D0098937F /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
+		C8D2C99D1695DEE10020C5F6 /* ObjectWithHTTPURLUppercaseScheme.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = ObjectWithHTTPURLUppercaseScheme.json; path = Data/ObjectWithHTTPURLUppercaseScheme.json; sourceTree = "<group>"; };
+		C8D2C9A01695DF010020C5F6 /* ObjectWithHTTPSURLUppercaseScheme.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = ObjectWithHTTPSURLUppercaseScheme.json; path = Data/ObjectWithHTTPSURLUppercaseScheme.json; sourceTree = "<group>"; };
 		C8E11E101691D69600C36062 /* VeriJSON.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VeriJSON.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		C8E11E141691D69600C36062 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		C8E11E161691D69600C36062 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
 				C8A207391695889F001CA314 /* ObjectWithHTTPURLPattern.json */,
 				C8A207371695889F001CA314 /* ObjectWithHTTPSURL.json */,
 				C8A207381695889F001CA314 /* ObjectWithHTTPURL.json */,
+				C8D2C99D1695DEE10020C5F6 /* ObjectWithHTTPURLUppercaseScheme.json */,
+				C8D2C9A01695DF010020C5F6 /* ObjectWithHTTPSURLUppercaseScheme.json */,
 			);
 			name = Data;
 			sourceTree = "<group>";
 				C8A2073B1695889F001CA314 /* ObjectWithHTTPURL.json in Resources */,
 				C8A2073C1695889F001CA314 /* ObjectWithHTTPURLPattern.json in Resources */,
 				C89CC44F1695BA0C009F5842 /* ObjectWithURLNonString.json in Resources */,
+				C8D2C99E1695DEE10020C5F6 /* ObjectWithHTTPURLUppercaseScheme.json in Resources */,
+				C8D2C9A11695DF010020C5F6 /* ObjectWithHTTPSURLUppercaseScheme.json in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

VeriJSON/VeriJSON/VeriJSON.m

 
 - (BOOL)verifyHTTPURL:(id)value {
     NSURL *url = [self urlFromValue:value];
-    NSString *scheme = [url scheme];
+    NSString *scheme = [[url scheme] lowercaseString];
     return [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"http"];
 }
 

VeriJSONTests/Data/ObjectWithHTTPSURLUppercaseScheme.json

+{
+    "self": "HTTP://example.com"
+}

VeriJSONTests/Data/ObjectWithHTTPURLUppercaseScheme.json

+{
+    "self": "HTTP://example.com"
+}

VeriJSONTests/VeriJSONTests.m

             [[@(valid) should] beYes];
         });
         
+        it(@"HTTP URL uppercase", ^{
+            id json = [bundle jsonFromResource:@"ObjectWithHTTPURLUppercaseScheme.json"];
+            BOOL valid = [veriJSON verifyJSON:json pattern:pattern];
+            [[@(valid) should] beYes];
+        });
+        
+        it(@"HTTPS URL uppercase", ^{
+            id json = [bundle jsonFromResource:@"ObjectWithHTTPSURLUppercaseScheme.json"];
+            BOOL valid = [veriJSON verifyJSON:json pattern:pattern];
+            [[@(valid) should] beYes];
+        });
+        
         it(@"relative URL", ^{
             id json = [bundle jsonFromResource:@"ObjectWithURLRelative.json"];
             BOOL valid = [veriJSON verifyJSON:json pattern:pattern];