aboutsummaryrefslogtreecommitdiff
path: root/Hutch/Extensions/Bundle+UserAgent.swift
blob: 2200576d9f994aa4f77108002c05a42d2f39e7bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Foundation

extension Bundle {
    /// The HTTP `User-Agent` string sent with all Hutch network requests.
    ///
    /// Format: `Hutch/<version>`
    var hutchUserAgent: String {
        let name = (object(forInfoDictionaryKey: "CFBundleDisplayName") as? String)
            ?? (object(forInfoDictionaryKey: "CFBundleName") as? String)
            ?? "Hutch"
        let version = (object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String) ?? "dev"
        return "\(name)/\(version)"
    }
}