Skip to content

Commit

Permalink
fix: Variable name 'DarwinVersion' should start with a lowercase char…
Browse files Browse the repository at this point in the history
…acter & device for mac
  • Loading branch information
zhouxl committed Mar 28, 2024
1 parent b42992c commit 9979dd2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Sources/Network/UserAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
//

import Foundation
#if os(iOS)
import UIKit

#elseif os(macOS)
import AppKit
#endif
// eg. Darwin/16.3.0
var DarwinVersion: String {
var darwinVersion: String {
var sysinfo = utsname()
uname(&sysinfo)
let dv = String(bytes: Data(bytes: &sysinfo.release, count: Int(_SYS_NAMELEN)), encoding: .ascii)!.trimmingCharacters(in: .controlCharacters)
Expand All @@ -25,8 +28,14 @@ var CFNetworkVersion: String {

// eg. iOS/10_1
var deviceVersion: String {
#if os(iOS)
let currentDevice = UIDevice.current
return "\(currentDevice.systemName)/\(currentDevice.systemVersion)"
#elseif os(macOS)
let info = ProcessInfo.processInfo
return "macOS/\(info.operatingSystemVersion.majorVersion).\(info.operatingSystemVersion.minorVersion).\(info.operatingSystemVersion.patchVersion)"
#endif

}

// eg. iPhone5,2
Expand All @@ -46,4 +55,4 @@ var appNameAndVersion: String {
return "\(name)/\(version)"
}

let userAgent = "\(appNameAndVersion) \(deviceName) \(deviceVersion) \(CFNetworkVersion) \(DarwinVersion)"
let userAgent = "\(appNameAndVersion) \(deviceName) \(deviceVersion) \(CFNetworkVersion) \(darwinVersion)"

0 comments on commit 9979dd2

Please sign in to comment.