mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-21 22:05:59 +00:00
Fix: iPad Name too long for QuickShare
This commit is contained in:
1 parent
cecffa1aaa
commit
1eebce1caa
2 files changed
+21
-2
No files matched your search
@@ -48,7 +48,7 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
|||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
self.deviceInfo = EndpointInfo(name: Host.current().localizedName ?? "Mac", deviceType: .computer)
|
self.deviceInfo = EndpointInfo(name: Host.current().localizedName ?? "Mac", deviceType: .computer)
|
||||||
#else
|
#else
|
||||||
self.deviceInfo = EndpointInfo(name: UIDevice.current.marketingName, deviceType: .phone)
|
self.deviceInfo = EndpointInfo(name: UIDevice.current.marketingName.withoutBracketedContent, deviceType: .phone)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tcpListener = try! NWListener(using: NWParameters(tls: .none))
|
tcpListener = try! NWListener(using: NWParameters(tls: .none))
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ extension Data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension SymmetricKey{
|
extension SymmetricKey {
|
||||||
func data() -> Data{
|
func data() -> Data{
|
||||||
return withUnsafeBytes({return Data(bytes: $0.baseAddress!, count: $0.count)})
|
return withUnsafeBytes({return Data(bytes: $0.baseAddress!, count: $0.count)})
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,25 @@ extension String {
|
|||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var withoutBracketedContent: String {
|
||||||
|
|
||||||
|
let input = self
|
||||||
|
|
||||||
|
// Replace any (...) including content inside, multiple times
|
||||||
|
let pattern = #"\([^)]*\)"#
|
||||||
|
let regex = try! NSRegularExpression(pattern: pattern, options: [])
|
||||||
|
|
||||||
|
// Remove all bracketed parts
|
||||||
|
let range = NSRange(location: 0, length: input.utf16.count)
|
||||||
|
var result = regex.stringByReplacingMatches(in: input, options: [], range: range, withTemplate: "")
|
||||||
|
|
||||||
|
// Remove extra spaces left behind
|
||||||
|
result = result.replacingOccurrences(of: " ", with: " ") // collapse double spaces
|
||||||
|
result = result.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user