Pass content of URL field to 'openLink' method
Previously, 'openLink' has chosen the first URL field contained in the password file. Since the action "Copy & Open" is performed on a specific field, only its content should be considered.
This commit is contained in:
parent
9b7fc4219e
commit
f8f858f15e
2 changed files with 13 additions and 10 deletions
|
|
@ -389,21 +389,24 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
}
|
||||
}
|
||||
|
||||
func openLink() {
|
||||
var urlString = self.password?.urlString ?? ""
|
||||
if !urlString.lowercased().starts(with: "https://") && !urlString.lowercased().starts(with: "http://") {
|
||||
urlString = "http://\(urlString)"
|
||||
}
|
||||
guard let url = URL(string: urlString) else {
|
||||
DispatchQueue.main.async {
|
||||
func openLink(to address: String?) {
|
||||
guard address != nil, let url = URL(string: formActualWebAddress(from: address!)) else {
|
||||
return DispatchQueue.main.async {
|
||||
Utils.alert(title: "Error", message: "Cannot find a valid URL", controller: self, completion: nil)
|
||||
}
|
||||
return;
|
||||
}
|
||||
SecurePasteboard.shared.copy(textToCopy: password?.password)
|
||||
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
|
||||
private func formActualWebAddress(from: String) -> String {
|
||||
let lowercased = from.lowercased()
|
||||
if !(lowercased.starts(with: "https://") || lowercased.starts(with: "http://")) {
|
||||
return "http://\(from)"
|
||||
}
|
||||
return from
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return tableData.count
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class LabelTableViewCell: UITableViewCell {
|
|||
|
||||
@objc func openLink(_ sender: Any?) {
|
||||
// if isURLCell, passwordTableView should not be nil
|
||||
delegatePasswordTableView!.openLink()
|
||||
delegatePasswordTableView!.openLink(to: cellData?.content)
|
||||
}
|
||||
|
||||
@objc func getNextHOTP(_ sender: Any?) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue