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

Code before:
    
    func singleValueContainer() throws -> SingleValueDecodingContainer {
        return SingleValueContainer(data: data, codingPath: codingPath, configuration: configuration)
    }
    
    struct SingleValueContainer: SingleValueDecodingContainer {
        let data: URLEncodedFormData
        var codingPath: [CodingKey]
        var configuration: URLEncodedFormDecoder.Configuration
        
        init(
            data: URLEncodedFormData,
            codingPath: [CodingKey],
            configuration: URLEncodedFormDecoder.Configuration
        ) {
            self.data = data
            self.codingPath = codingPath
            self.configuration = configuration
        }
        
        func decodeNil() -> Bool {
            self.data.values.isEmpty
        }
        
        func decode<T>(_ type: T.Type) throws -> T where T: Decodable {
            //Check if we received a date. We need the decode with the appropriate format
            guard !(T.self is Date.Type) else {
                return try configuration.decodeDate(from: data, codingPath: codingPath, forKey: nil) as! T
            }
            if let convertible = T.self as? URLQueryFragmentConvertible.Type {
              guard let value = data.values.last else {
                    throw DecodingError.valueNotFound(T.self, at: self.codingPath)
                }
                if let result = convertible.init(urlQueryFragmentValue: value) {
                    return result as! T
                } else {
                    throw DecodingError.typeMismatch(T.self, at: self.codingPath)
                }
            } else {
                let decoder = _Decoder(data: data, codingPath: self.codingPath, configuration: configuration)
                return try T(from: decoder)
            }
        }
    }
}

private extension URLEncodedFormDecoder.Configuration {
    func decodeDate(from data: URLEncodedFormData, codingPath: [CodingKey], forKey key: CodingKey?) throws -> Date {
        let newCodingPath = codingPath + (key.map { [$0] } ?? [])
        switch dateDecodingStrategy {
        case .secondsSince1970:

Review comment (suggestion):
```suggestion
            // Check if we received a date. We need the decode with the appropriate format.
```

Code after:
    
    func singleValueContainer() throws -> SingleValueDecodingContainer {
        return SingleValueContainer(data: data, codingPath: codingPath, configuration: configuration)
    }
    
    struct SingleValueContainer: SingleValueDecodingContainer {
        let data: URLEncodedFormData
        var codingPath: [CodingKey]
        var configuration: URLEncodedFormDecoder.Configuration
        
        init(
            data: URLEncodedFormData,
            codingPath: [CodingKey],
            configuration: URLEncodedFormDecoder.Configuration
        ) {
            self.data = data
            self.codingPath = codingPath
            self.configuration = configuration
        }
        
        func decodeNil() -> Bool {
            self.data.values.isEmpty
        }
        
        func decode<T>(_ type: T.Type) throws -> T where T: Decodable {
            // Check if we received a date. We need the decode with the appropriate format.
            guard !(T.self is Date.Type) else {
                return try configuration.decodeDate(from: data, codingPath: codingPath, forKey: nil) as! T
            }
            if let convertible = T.self as? URLQueryFragmentConvertible.Type {
              guard let value = data.values.last else {
                    throw DecodingError.valueNotFound(T.self, at: self.codingPath)
                }
                if let result = convertible.init(urlQueryFragmentValue: value) {
                    return result as! T
                } else {
                    throw DecodingError.typeMismatch(T.self, at: self.codingPath)
                }
            } else {
                let decoder = _Decoder(data: data, codingPath: self.codingPath, configuration: configuration)
                return try T(from: decoder)
            }
        }
    }
}

private extension URLEncodedFormDecoder.Configuration {
    func decodeDate(from data: URLEncodedFormData, codingPath: [CodingKey], forKey key: CodingKey?) throws -> Date {
        let newCodingPath = codingPath + (key.map { [$0] } ?? [])
        switch dateDecodingStrategy {
        case .secondsSince1970: