[BUG]Fixed decoding ss url.

Base64 string may containe character '/'.
This commit is contained in:
Charlie Qiu
2017-01-12 11:31:38 +08:00
parent 1de6fa0b5a
commit 5099e0bcc0

View File

@ -42,9 +42,11 @@ class ServerProfile: NSObject, NSCopying {
} }
func decodeUrl(url: URL?) -> String? { func decodeUrl(url: URL?) -> String? {
guard let encodedStr = url?.host else { guard let urlStr = url?.absoluteString else {
return nil return nil
} }
let index = urlStr.index(urlStr.startIndex, offsetBy: 5)
let encodedStr = urlStr.substring(from: index)
guard let data = Data(base64Encoded: padBase64(string: encodedStr)) else { guard let data = Data(base64Encoded: padBase64(string: encodedStr)) else {
return url?.absoluteString return url?.absoluteString
} }