Fix inconsistencies found by consistency audit of 395f76e

This commit is contained in:
Ian Gulliver
2026-10-23 11:48:42 -07:00
parent 836d3019ac
commit f1d3f9be61
17 changed files with 376 additions and 362 deletions
+9 -4
View File
@@ -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)