Browse Source

Moved MIMEType component logic inside a closure to make intent clearer.

Christian Noon 10 years ago
parent
commit
27c1b2a6ab
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Source/Validation.swift

+ 5 - 3
Source/Validation.swift

@@ -72,9 +72,11 @@ extension Request {
         let subtype: String
         let subtype: String
 
 
         init?(_ string: String) {
         init?(_ string: String) {
-            let stripped = string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
-            let split = stripped.substringToIndex(stripped.rangeOfString(";")?.endIndex ?? stripped.endIndex)
-            let components = split.componentsSeparatedByString("/")
+            let components: [String] = {
+                let stripped = string.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
+                let split = stripped.substringToIndex(stripped.rangeOfString(";")?.endIndex ?? stripped.endIndex)
+                return split.componentsSeparatedByString("/")
+            }()
 
 
             if let
             if let
                 type = components.first,
                 type = components.first,