summaryrefslogtreecommitdiff
path: root/Hutch/Extensions/Bundle+UserAgent.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hutch/Extensions/Bundle+UserAgent.swift')
-rw-r--r--Hutch/Extensions/Bundle+UserAgent.swift14
1 files changed, 14 insertions, 0 deletions
diff --git a/Hutch/Extensions/Bundle+UserAgent.swift b/Hutch/Extensions/Bundle+UserAgent.swift
new file mode 100644
index 0000000..2200576
--- /dev/null
+++ b/Hutch/Extensions/Bundle+UserAgent.swift
@@ -0,0 +1,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)"
+ }
+}