chore: ClashProxyType ignore case

This commit is contained in:
mrFq1 2023-06-19 15:02:10 +08:00
parent ec304e7b56
commit fba1c7d6ea
1 changed files with 9 additions and 2 deletions

View File

@ -9,7 +9,7 @@
import Cocoa
import SwiftyJSON
enum ClashProxyType: String, Codable {
enum ClashProxyType: String, Codable, CaseIterable {
case urltest = "URLTest"
case fallback = "Fallback"
case loadBalance = "LoadBalance"
@ -27,7 +27,6 @@ enum ClashProxyType: String, Codable {
case vless = "Vless"
case hysteria = "Hysteria"
case wireguardMeta = "WireGuard"
case wireguard = "Wireguard"
case tuic = "Tuic"
@ -35,6 +34,14 @@ enum ClashProxyType: String, Codable {
case unknown = "Unknown"
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let rawString = try container.decode(String.self)
self = ClashProxyType.allCases.first(where: { $0.rawValue.caseInsensitiveCompare(rawString) == .orderedSame }) ?? .unknown
}
static let proxyGroups: [ClashProxyType] = [.select, .urltest, .fallback, .loadBalance]
var isAutoGroup: Bool {