fix(ios): improve bridge discovery and pairing UX

This commit is contained in:
Peter Steinberger
2025-12-13 17:58:03 +00:00
parent 61ab07ced3
commit 7c3502f031
6 changed files with 263 additions and 83 deletions

View File

@@ -6,8 +6,9 @@ enum BridgeEndpointID {
static func stableID(_ endpoint: NWEndpoint) -> String {
switch endpoint {
case let .service(name, type, domain, _):
// Keep this stable across encode/decode differences; use raw service tuple.
"\(type)|\(domain)|\(name)"
// Keep this stable across encode/decode differences (e.g. `\032` for spaces).
let normalizedName = Self.normalizeServiceNameForID(name)
return "\(type)|\(domain)|\(normalizedName)"
default:
String(describing: endpoint)
}
@@ -16,4 +17,10 @@ enum BridgeEndpointID {
static func prettyDescription(_ endpoint: NWEndpoint) -> String {
BonjourEscapes.decode(String(describing: endpoint))
}
private static func normalizeServiceNameForID(_ rawName: String) -> String {
let decoded = BonjourEscapes.decode(rawName)
let normalized = decoded.split(whereSeparator: \.isWhitespace).joined(separator: " ")
return normalized.trimmingCharacters(in: .whitespacesAndNewlines)
}
}