2017-02-11 23:45:00 +08:00
|
|
|
//
|
|
|
|
|
// PasswordEntity.swift
|
|
|
|
|
// pass
|
|
|
|
|
//
|
|
|
|
|
// Created by Mingshen Sun on 11/2/2017.
|
|
|
|
|
// Copyright © 2017 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
import SwiftyUserDefaults
|
|
|
|
|
|
|
|
|
|
extension PasswordEntity {
|
2017-03-16 00:38:38 +08:00
|
|
|
|
|
|
|
|
var nameWithCategory: String {
|
|
|
|
|
get {
|
|
|
|
|
if let p = path, p.hasSuffix(".gpg") {
|
|
|
|
|
return p.substring(to: p.index(p.endIndex, offsetBy: -4))
|
|
|
|
|
} else {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 23:01:56 -08:00
|
|
|
func getCategoryText() -> String {
|
|
|
|
|
var parentEntity = parent
|
|
|
|
|
var passwordCategoryArray: [String] = []
|
|
|
|
|
while parentEntity != nil {
|
|
|
|
|
passwordCategoryArray.append(parentEntity!.name!)
|
|
|
|
|
parentEntity = parentEntity!.parent
|
|
|
|
|
}
|
|
|
|
|
passwordCategoryArray.reverse()
|
|
|
|
|
return passwordCategoryArray.joined(separator: " > ")
|
|
|
|
|
}
|
2017-04-25 13:01:17 -07:00
|
|
|
|
|
|
|
|
func getURL() -> URL? {
|
|
|
|
|
if let p = path {
|
2017-04-26 20:28:15 -07:00
|
|
|
return URL(string: p.stringByAddingPercentEncodingForRFC3986()!)
|
2017-04-25 13:01:17 -07:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2017-02-11 23:45:00 +08:00
|
|
|
}
|