NSE user agent support (#1507)

This commit is contained in:
Mauro
2023-08-17 15:11:34 +02:00
committed by GitHub
parent a11325bcb4
commit 8188fd2d2a
8 changed files with 31 additions and 9 deletions
@@ -29,6 +29,9 @@ struct InfoPlistReader {
/// Info.plist reader on the bundle object that contains the current executable.
static let main = InfoPlistReader(bundle: .main)
/// Info.plist reader on the bundle object that contains the main app executable.
static let app = InfoPlistReader(bundle: .app)
private let bundle: Bundle
/// Initializer
@@ -22,13 +22,13 @@ import DeviceKit
#endif
final class UserAgentBuilder {
class func makeASCIIUserAgent() -> String? {
makeUserAgent()?.asciified()
class func makeASCIIUserAgent() -> String {
makeUserAgent()?.asciified() ?? "unknown"
}
private class func makeUserAgent() -> String? {
let clientName = InfoPlistReader.main.bundleDisplayName
let clientVersion = InfoPlistReader.main.bundleShortVersionString
let clientName = InfoPlistReader.app.bundleDisplayName
let clientVersion = InfoPlistReader.app.bundleShortVersionString
#if os(iOS)
return String(format: "%@/%@ (%@; iOS %@; Scale/%0.2f)",