Avoid inline format for non-descriptive strings (#302)
This commit is contained in:
parent
b89328b5c3
commit
fb47def4ed
|
@ -172,7 +172,7 @@ extension Constants {
|
|||
}
|
||||
|
||||
private static func containerPath(filename: String) -> String {
|
||||
"\(parentPath)/\(filename)"
|
||||
[parentPath, filename].joined(separator: "/")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,18 +28,18 @@ import TunnelKitCore
|
|||
|
||||
extension Endpoint: Identifiable {
|
||||
public var id: String {
|
||||
"\(address):\(proto.port):\(proto.socketType.rawValue)"
|
||||
[address, proto.port.description, proto.socketType.rawValue].joined(separator: ":")
|
||||
}
|
||||
}
|
||||
|
||||
extension IPv4Settings.Route: Identifiable {
|
||||
public var id: String {
|
||||
"\(destination):\(mask):\(gateway ?? "*")"
|
||||
[destination, mask, gateway ?? "*"].joined(separator: ":")
|
||||
}
|
||||
}
|
||||
|
||||
extension IPv6Settings.Route: Identifiable {
|
||||
public var id: String {
|
||||
"\(destination):\(prefixLength):\(gateway ?? "*")"
|
||||
[destination, prefixLength.description, gateway ?? "*"].joined(separator: ":")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,11 @@ enum Unlocalized {
|
|||
|
||||
enum Keychain {
|
||||
static func passwordEntry(_ profile: Profile) -> String {
|
||||
"\(profile.id.uuidString):\(profile.currentVPNProtocol.keychainEntry):\(profile.account.username)"
|
||||
[
|
||||
profile.id.uuidString,
|
||||
profile.currentVPNProtocol.keychainEntry,
|
||||
profile.account.username
|
||||
].joined(separator: ":")
|
||||
}
|
||||
|
||||
static func passwordLabel(_ profile: Profile) -> String {
|
||||
|
|
|
@ -115,8 +115,11 @@ public final class GenericWebServices<ErrorType: GenericWebServicesError> {
|
|||
|
||||
private func url(forEndpoint endpoint: GenericWebEndpoint) -> URL {
|
||||
guard let version = version else {
|
||||
return root.appendingPathComponent(endpoint.path)
|
||||
return root
|
||||
.appendingPathComponent(endpoint.path)
|
||||
}
|
||||
return root.appendingPathComponent("\(version)/\(endpoint.path)")
|
||||
return root
|
||||
.appendingPathComponent(version)
|
||||
.appendingPathComponent(endpoint.path)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,6 @@ public protocol KeyValueStore {
|
|||
|
||||
extension KeyStoreDomainLocation {
|
||||
public var key: String {
|
||||
"\(domain).\(rawValue)"
|
||||
[domain, rawValue].joined(separator: ".")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,9 @@ extension Utils {
|
|||
remainder %= base
|
||||
base >>= 8
|
||||
}
|
||||
return groups.map { "\($0)" }.joined(separator: ".")
|
||||
return groups
|
||||
.map { $0.description }
|
||||
.joined(separator: ".")
|
||||
}
|
||||
|
||||
public static func ipv4(fromString string: String) -> UInt32? {
|
||||
|
|
|
@ -31,19 +31,19 @@ import PassepartoutCore
|
|||
|
||||
extension ProviderCategory: Identifiable {
|
||||
public var id: String {
|
||||
"\(providerMetadata.name):\(name)"
|
||||
[providerMetadata.name, name].joined(separator: ":")
|
||||
}
|
||||
}
|
||||
|
||||
extension ProviderLocation: Identifiable {
|
||||
public var id: String {
|
||||
"\(providerMetadata.name):\(categoryName):\(countryCode)"
|
||||
[providerMetadata.name, categoryName, countryCode].joined(separator: ":")
|
||||
}
|
||||
}
|
||||
|
||||
extension ProviderServer: Identifiable {
|
||||
public var locationId: String {
|
||||
"\(providerMetadata.name):\(categoryName):\(countryCode)"
|
||||
[providerMetadata.name, categoryName, countryCode].joined(separator: ":")
|
||||
}
|
||||
|
||||
public func location(withVPNProtocol vpnProtocol: VPNProtocolType) -> ProviderLocation {
|
||||
|
@ -57,7 +57,7 @@ extension ProviderServer: Identifiable {
|
|||
}
|
||||
|
||||
public static func id(withName providerName: ProviderName, vpnProtocol: VPNProtocolType, apiId: String) -> String? {
|
||||
let idSource = "\(providerName):\(vpnProtocol.rawValue):\(apiId)"
|
||||
let idSource = [providerName, vpnProtocol.rawValue, apiId].joined(separator: ":")
|
||||
guard let data = idSource.data(using: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ public final class APIWebServices: WebServices {
|
|||
private var pathName: String {
|
||||
switch self {
|
||||
case .providersIndex:
|
||||
return "\(Group.providers.rawValue)/index"
|
||||
return [Group.providers.rawValue, "index"].joined(separator: "/")
|
||||
|
||||
case .providerNetwork(let providerName, let vpnProtocol):
|
||||
return "\(Group.providers.rawValue)/\(providerName)/\(vpnProtocol.filename)"
|
||||
return [Group.providers.rawValue, providerName, vpnProtocol.filename].joined(separator: "/")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public final class APIWebServices: WebServices {
|
|||
// MARK: GenericWebEndpoint
|
||||
|
||||
var path: String {
|
||||
"\(pathName).\(fileType)"
|
||||
[pathName, fileType].joined(separator: ".")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ extension Profile.Header {
|
|||
}
|
||||
suffix = leadingUUID.lowercased()
|
||||
}
|
||||
let newName = "\(name).\(suffix)"
|
||||
let newName = [name, suffix].joined(separator: ".")
|
||||
return renamed(to: newName)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,11 +242,9 @@ extension DefaultUpgradeStrategy {
|
|||
throw MigrationError.missingEndpointProtocols
|
||||
}
|
||||
let eps = rawEps.compactMap(EndpointProtocol.init(rawValue:))
|
||||
var remotes: [String] = []
|
||||
eps.forEach {
|
||||
remotes.append("\(hostname):\($0)")
|
||||
ovpn["remotes"] = eps.map {
|
||||
[hostname, $0.description].joined(separator: ":")
|
||||
}
|
||||
ovpn["remotes"] = remotes
|
||||
ovpn["authUserPass"] = authUserPass.contains(oldUUIDString)
|
||||
let cfg = try JSON(ovpn).decode(OpenVPN.Configuration.self)
|
||||
|
||||
|
@ -292,9 +290,13 @@ extension DefaultUpgradeStrategy {
|
|||
settings.serverId = ProviderServer.id(withName: name, vpnProtocol: .openVPN, apiId: apiId)
|
||||
}
|
||||
settings.presetId = providerMap["presetId"] as? String
|
||||
settings.favoriteLocationIds = Set((providerMap["favoriteGroupIds"] as? [String])?.compactMap {
|
||||
"\(name):\($0.replacingOccurrences(of: "/", with: ":"))"
|
||||
} ?? [])
|
||||
let favoriteGroupIds = providerMap["favoriteGroupIds"] as? [String] ?? []
|
||||
settings.favoriteLocationIds = Set(favoriteGroupIds.compactMap {
|
||||
[
|
||||
name,
|
||||
$0.replacingOccurrences(of: "/", with: ":")
|
||||
].joined(separator: ":")
|
||||
})
|
||||
settings.account = account
|
||||
provider.vpnSettings[.openVPN] = settings
|
||||
|
||||
|
@ -309,7 +311,7 @@ extension DefaultUpgradeStrategy {
|
|||
|
||||
private func migratedV1Password(forProfileId profileId: String, profileType: String, username: String) -> String {
|
||||
let keychain = Keychain(group: appGroup)
|
||||
let passwordContext = "\(Bundle.main.bundleIdentifier!).\(profileType).\(profileId)"
|
||||
let passwordContext = [Bundle.main.bundleIdentifier!, profileType, profileId].joined(separator: ".")
|
||||
do {
|
||||
return try keychain.password(for: username, context: passwordContext)
|
||||
} catch {
|
||||
|
|
Loading…
Reference in New Issue