diff --git a/Passepartout/App/Constants/Constants+App.swift b/Passepartout/App/Constants/Constants+App.swift index 0f799ebe..666a0f11 100644 --- a/Passepartout/App/Constants/Constants+App.swift +++ b/Passepartout/App/Constants/Constants+App.swift @@ -172,7 +172,7 @@ extension Constants { } private static func containerPath(filename: String) -> String { - "\(parentPath)/\(filename)" + [parentPath, filename].joined(separator: "/") } } diff --git a/Passepartout/App/Extensions/TunnelKit+Identifiable.swift b/Passepartout/App/Extensions/TunnelKit+Identifiable.swift index 566299c9..fe0a7b12 100644 --- a/Passepartout/App/Extensions/TunnelKit+Identifiable.swift +++ b/Passepartout/App/Extensions/TunnelKit+Identifiable.swift @@ -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: ":") } } diff --git a/Passepartout/AppShared/L10n/Unlocalized.swift b/Passepartout/AppShared/L10n/Unlocalized.swift index 7decd06b..ddc3a9ec 100644 --- a/Passepartout/AppShared/L10n/Unlocalized.swift +++ b/Passepartout/AppShared/L10n/Unlocalized.swift @@ -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 { diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/GenericWebServices.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/GenericWebServices.swift index 4606f041..66a08a3a 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/GenericWebServices.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/GenericWebServices.swift @@ -115,8 +115,11 @@ public final class GenericWebServices { 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) } } diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/KeyValueStore.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/KeyValueStore.swift index 61a58155..6a5eff2a 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/KeyValueStore.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Reusable/KeyValueStore.swift @@ -43,6 +43,6 @@ public protocol KeyValueStore { extension KeyStoreDomainLocation { public var key: String { - "\(domain).\(rawValue)" + [domain, rawValue].joined(separator: ".") } } diff --git a/PassepartoutLibrary/Sources/PassepartoutCore/Utils/Utils+Network.swift b/PassepartoutLibrary/Sources/PassepartoutCore/Utils/Utils+Network.swift index a0a27e9f..31f43ae8 100644 --- a/PassepartoutLibrary/Sources/PassepartoutCore/Utils/Utils+Network.swift +++ b/PassepartoutLibrary/Sources/PassepartoutCore/Utils/Utils+Network.swift @@ -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? { diff --git a/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift b/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift index b7385c24..534a9e97 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProviders/Extensions/Domain+Identifiable.swift @@ -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 } diff --git a/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/APIWebServices.swift b/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/APIWebServices.swift index 60300ff8..f2f7fe0a 100644 --- a/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/APIWebServices.swift +++ b/PassepartoutLibrary/Sources/PassepartoutProvidersImpl/Strategies/APIWebServices.swift @@ -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: ".") } } diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/Profile+Extensions.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/Profile+Extensions.swift index f0831b84..4c869400 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/Profile+Extensions.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/Profile+Extensions.swift @@ -84,7 +84,7 @@ extension Profile.Header { } suffix = leadingUUID.lowercased() } - let newName = "\(name).\(suffix)" + let newName = [name, suffix].joined(separator: ".") return renamed(to: newName) } } diff --git a/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Strategies/DefaultUpgradeStrategy.swift b/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Strategies/DefaultUpgradeStrategy.swift index f5281fc2..6dcf183f 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Strategies/DefaultUpgradeStrategy.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Strategies/DefaultUpgradeStrategy.swift @@ -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 {