chore: ClashProxyType ignore case

This commit is contained in:
mrFq1
2023-06-19 15:02:00 +08:00
parent f3d3d7094a
commit e07050c08c

View File

@@ -9,7 +9,7 @@
import Cocoa import Cocoa
import SwiftyJSON import SwiftyJSON
enum ClashProxyType: String, Codable { enum ClashProxyType: String, Codable, CaseIterable {
case urltest = "URLTest" case urltest = "URLTest"
case fallback = "Fallback" case fallback = "Fallback"
case loadBalance = "LoadBalance" case loadBalance = "LoadBalance"
@@ -27,7 +27,6 @@ enum ClashProxyType: String, Codable {
case vless = "Vless" case vless = "Vless"
case hysteria = "Hysteria" case hysteria = "Hysteria"
case wireguardMeta = "WireGuard"
case wireguard = "Wireguard" case wireguard = "Wireguard"
case tuic = "Tuic" case tuic = "Tuic"
@@ -35,6 +34,13 @@ enum ClashProxyType: String, Codable {
case unknown = "Unknown" 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] static let proxyGroups: [ClashProxyType] = [.select, .urltest, .fallback, .loadBalance]
var isAutoGroup: Bool { var isAutoGroup: Bool {