krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

v3.2.0: Hutch/Extensions/Bundle+UserAgent.swift · raw

 1import Foundation
 2
 3extension Bundle {
 4    /// The HTTP `User-Agent` string sent with all Hutch network requests.
 5    ///
 6    /// Format: `Hutch/<version>`
 7    var hutchUserAgent: String {
 8        let name = (object(forInfoDictionaryKey: "CFBundleDisplayName") as? String)
 9            ?? (object(forInfoDictionaryKey: "CFBundleName") as? String)
10            ?? "Hutch"
11        let version = (object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String) ?? "dev"
12        return "\(name)/\(version)"
13    }
14}