From b50cb4681b35f8ca346f1919e3ead4c5edc0591b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 7 Mar 2019 23:54:53 +0100 Subject: [PATCH] Fix stupid parsing of ProfileKey from String Fixes #19 --- CHANGELOG.md | 6 ++++++ Passepartout/Sources/Model/Profiles/ProfileKey.swift | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abd4cb99..e49f5f7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Hosts gone while connected (credit to Aston Martin). [#19](https://github.com/passepartoutvpn/passepartout-ios/issues/19) + ## 1.1.0 Beta 1334 (2019-03-07) ### Added diff --git a/Passepartout/Sources/Model/Profiles/ProfileKey.swift b/Passepartout/Sources/Model/Profiles/ProfileKey.swift index 4d99c62b..73b20cb4 100644 --- a/Passepartout/Sources/Model/Profiles/ProfileKey.swift +++ b/Passepartout/Sources/Model/Profiles/ProfileKey.swift @@ -47,14 +47,15 @@ struct ProfileKey: RawRepresentable, Hashable, Codable { } init?(rawValue: String) { - let comps = rawValue.components(separatedBy: ".") - guard comps.count == 2 else { + var comps = rawValue.components(separatedBy: ".") + guard comps.count >= 2 else { return nil } guard let context = Context(rawValue: comps[0]) else { return nil } self.context = context - id = comps[1] + comps.removeFirst() + id = comps.joined(separator: ".") } }