mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-26 17:43:22 +01:00
29 lines
475 B
Swift
29 lines
475 B
Swift
//
|
|
// Dictionary+Parser.swift
|
|
//
|
|
//
|
|
// Created by Brent Simmons on 8/18/24.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public 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
|
|
}
|
|
}
|