Commits

dcutting committed bb7cad0

HTTP/HTTPS.

Comments (0)

Files changed (2)

VeriJSON/VeriJSON/VeriJSON.m

 }
 
 - (BOOL)verifyHTTPURL:(NSString *)value {
-    return YES;
+    NSURL *url = [NSURL URLWithString:value];
+    NSString *scheme = [url scheme];
+    return [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"http"];
 }
 
 - (NSError *)buildErrorFromPatternStack:(NSArray *)patternStack {

VeriJSONTests/VeriJSONTests.m

             pattern = [bundle jsonFromResource:@"ObjectWithHTTPURLPattern.json"];
         });
         
-        it(@"URL", ^{
+        it(@"HTTP URL", ^{
             id json = [bundle jsonFromResource:@"ObjectWithHTTPURL.json"];
             BOOL valid = [veriJSON verifyJSON:json pattern:pattern];
             [[@(valid) should] beYes];
         });
+        
+        it(@"HTTPS URL", ^{
+            id json = [bundle jsonFromResource:@"ObjectWithHTTPSURL.json"];
+            BOOL valid = [veriJSON verifyJSON:json pattern:pattern];
+            [[@(valid) should] beYes];
+        });
+
+        it(@"non-HTTP URL", ^{
+            id json = [bundle jsonFromResource:@"ObjectWithURL.json"];
+            BOOL valid = [veriJSON verifyJSON:json pattern:pattern];
+            [[@(valid) should] beNo];
+        });
     });
     
     it(@"hack to ensure tests finish", ^{