Fix stupid parsing of ProfileKey from String

Fixes #19
This commit is contained in:
Davide De Rosa 2019-03-07 23:54:53 +01:00
parent 786d5d2782
commit b50cb4681b
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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: ".")
}
}