NetNewsWire/Modules/Parser/Sources/SAX/Extensions/Dictionary+SAX.swift

29 lines
468 B
Swift
Raw Normal View History

//
// Dictionary+Parser.swift
//
//
// Created by Brent Simmons on 8/18/24.
//
import Foundation
extension Dictionary where Key == String, Value == String {
func object(forCaseInsensitiveKey key: String) -> String? {
if let object = self[key] {
return object
}
let lowercaseKey = key.lowercased()
for (oneKey, oneValue) in self {
if lowercaseKey.caseInsensitiveCompare(oneKey) == .orderedSame {
return oneValue
}
}
return nil
}
}