Change key value separator from ":" to ": "
This commit is contained in:
parent
68229dc944
commit
72e2fcf0b5
1 changed files with 6 additions and 2 deletions
|
|
@ -99,12 +99,16 @@ class Password {
|
||||||
// return a key-value pair from the line
|
// return a key-value pair from the line
|
||||||
// key might be nil, if there is no ":" in the line
|
// key might be nil, if there is no ":" in the line
|
||||||
static private func getKeyValuePair(from line: String) -> (key: String?, value: String) {
|
static private func getKeyValuePair(from line: String) -> (key: String?, value: String) {
|
||||||
let items = line.characters.split(separator: ":", maxSplits: 1, omittingEmptySubsequences: false).map{String($0).trimmingCharacters(in: .whitespaces)}
|
let items = line.components(separatedBy: ": ").map{String($0).trimmingCharacters(in: .whitespaces)}
|
||||||
var key : String? = nil
|
var key : String? = nil
|
||||||
var value = ""
|
var value = ""
|
||||||
if items.count == 1 || (items[0].isEmpty && items[1].isEmpty) {
|
if items.count == 1 || (items[0].isEmpty && items[1].isEmpty) {
|
||||||
// no ":" found, or empty on both sides of ":" (e.g., " : ")
|
// no ": " found, or empty on both sides of ": "
|
||||||
value = line
|
value = line
|
||||||
|
// otpauth special case
|
||||||
|
if value.hasPrefix("otpauth://") {
|
||||||
|
key = "otpauth"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if !items[0].isEmpty {
|
if !items[0].isEmpty {
|
||||||
key = items[0]
|
key = items[0]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue