Repository: vapor/vapor
File: Sources/Vapor/URLEncodedForm/URLEncodedFormDecoder.swift (Swift)

Code before:
            data: URLEncodedFormData,
            codingPath: [CodingKey],
            configuration: URLEncodedFormDecoder.Configuration
        ) throws {
            self.data = data
            self.codingPath = codingPath
            self.configuration = configuration
            self.currentIndex = 0
            // Did we get an array with arr[0]=a&arr[1]=b indexing?
            // Cache this result
            self.allChildKeysAreNumbers = data.children.count > 0 && data.allChildKeysAreSequentialIntegers
            
            if allChildKeysAreNumbers {
                self.values = data.values
            } else {
                // No we got an array with arr[]=a&arr[]=b or arr=a&arr=b
                var values = data.values
                // empty brackets turn into empty strings!
                if let valuesInBracket = data.children[""] {
                    values = values + valuesInBracket.values
                }
                
                // parse out any character separated array values
                self.values = try values.flatMap { value in
                    try value.asUrlEncoded().split(omittingEmptySubsequences: false) {
                        configuration.arraySeparators.contains($0)
                    }.map { (ss: Substring) in
                        URLQueryFragment.urlEncoded(String(ss))
                    }
                }
            }
        }
        
        func decodeNil() throws -> Bool {
            return false
        }
        
        struct _CodingKey: CodingKey {
            var stringValue: String
            
            init(stringValue: String) {
                self.stringValue = stringValue
            }
            
            var intValue: Int?
            
            init?(intValue: Int) {
                self.intValue = intValue
                self.stringValue = String(intValue)
            }
        }

Review comment (suggestion):
LGTM, but I've got I feel like we should change this to:
`split(omittingEmptySubsequences: false, whereSeparator: configuration.arraySeparators.contains)`

Code after:
            data: URLEncodedFormData,
            codingPath: [CodingKey],
            configuration: URLEncodedFormDecoder.Configuration
        ) throws {
            self.data = data
            self.codingPath = codingPath
            self.configuration = configuration
            self.currentIndex = 0
            // Did we get an array with arr[0]=a&arr[1]=b indexing?
            // Cache this result
            self.allChildKeysAreNumbers = data.children.count > 0 && data.allChildKeysAreSequentialIntegers
            
            if allChildKeysAreNumbers {
                self.values = data.values
            } else {
                // No we got an array with arr[]=a&arr[]=b or arr=a&arr=b
                var values = data.values
                // empty brackets turn into empty strings!
                if let valuesInBracket = data.children[""] {
                    values = values + valuesInBracket.values
                }
                
                // parse out any character separated array values
                self.values = try values.flatMap { value in
                    try value.asUrlEncoded()
                        .split(omittingEmptySubsequences: false,
                               whereSeparator: configuration.arraySeparators.contains)
                        .map { (ss: Substring) in
                            URLQueryFragment.urlEncoded(String(ss))
                        }
                }
            }
        }
        
        func decodeNil() throws -> Bool {
            return false
        }
        
        struct _CodingKey: CodingKey {
            var stringValue: String
            
            init(stringValue: String) {
                self.stringValue = stringValue
            }
            
            var intValue: Int?
            
            init?(intValue: Int) {
                self.intValue = intValue
                self.stringValue = String(intValue)
            }