Fix inconsistencies found by consistency audit of 395f76e
This commit is contained in:
@@ -371,16 +371,21 @@ func consoleLine(_ level: String, _ text: String, _ url: String?, _ line: Int?)
|
||||
// into this profile. A live port alone does not identify our browser.
|
||||
func chromeFromProfile() async -> Chrome? {
|
||||
let activePort = URL(filePath: chromeProfile).appending(path: "DevToolsActivePort")
|
||||
guard let text = try? String(contentsOf: activePort, encoding: .utf8) else { return nil }
|
||||
guard let text = try? String(contentsOf: activePort, encoding: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
let lines = text.split(whereSeparator: \.isNewline)
|
||||
guard lines.count == 2, let port = Int(lines[0]), (1...65535).contains(port),
|
||||
lines[1].hasPrefix("/devtools/browser/") else { return nil }
|
||||
guard lines.count == 2, let port = Int(lines[0]), (1...65535).contains(port), lines[1].hasPrefix("/devtools/browser/") else {
|
||||
return nil
|
||||
}
|
||||
var endpoint = URLComponents()
|
||||
endpoint.scheme = "ws"
|
||||
endpoint.host = "127.0.0.1"
|
||||
endpoint.port = port
|
||||
endpoint.path = String(lines[1])
|
||||
guard let url = endpoint.url else { return nil }
|
||||
guard let url = endpoint.url else {
|
||||
return nil
|
||||
}
|
||||
let chrome = Chrome(url)
|
||||
do {
|
||||
_ = try await chrome.send("Browser.getVersion", timeout: 2)
|
||||
|
||||
Reference in New Issue
Block a user