@@ -26,21 +26,21 @@ import Foundation
26
26
internal struct Headers {
27
27
static let purpose = " Sec-Purpose "
28
28
static let purposePrefetch = " prefetch "
29
-
29
+
30
30
static let prefersColorScheme = " Sec-CH-Prefers-Color-Scheme "
31
-
31
+
32
32
static let branding = " X-Shopify-Checkout-Kit-Branding "
33
33
static let brandingCheckoutKit = " CHECKOUT_KIT "
34
34
static let brandingWeb = " WEB_DEFAULT "
35
35
}
36
36
37
37
internal func checkoutKitHeaders( isPreload: Bool = false ) -> [ String : String ] {
38
38
var headers = [ String: String] ( )
39
-
39
+
40
40
if isPreload {
41
41
headers [ Headers . purpose] = Headers . purposePrefetch
42
42
}
43
-
43
+
44
44
return headers
45
45
. withColorScheme ( )
46
46
. withBranding ( )
@@ -49,7 +49,7 @@ internal func checkoutKitHeaders(isPreload: Bool = false) -> [String: String] {
49
49
internal extension Dictionary where Key == String , Value == String {
50
50
func withColorScheme( ) -> [ String : String ] {
51
51
var headers = self
52
-
52
+
53
53
let colorScheme = ShopifyCheckoutSheetKit . configuration. colorScheme
54
54
switch colorScheme {
55
55
case . light:
@@ -59,35 +59,35 @@ internal extension Dictionary where Key == String, Value == String {
59
59
case . automatic, . web:
60
60
break // Don't add header for automatic or web color schemes
61
61
}
62
-
62
+
63
63
return headers
64
64
}
65
-
65
+
66
66
func withBranding( ) -> [ String : String ] {
67
67
var headers = self
68
-
68
+
69
69
let colorScheme = ShopifyCheckoutSheetKit . configuration. colorScheme
70
70
switch colorScheme {
71
71
case . web:
72
72
headers [ Headers . branding] = Headers . brandingWeb
73
73
default :
74
74
headers [ Headers . branding] = Headers . brandingCheckoutKit
75
75
}
76
-
76
+
77
77
return headers
78
78
}
79
-
79
+
80
80
func hasColorSchemeHeader( ) -> Bool {
81
81
return hasHeader ( Headers . prefersColorScheme)
82
82
}
83
-
83
+
84
84
func hasBrandingHeader( ) -> Bool {
85
85
return hasHeader ( Headers . branding)
86
86
}
87
-
87
+
88
88
private func hasHeader( _ headerName: String ) -> Bool {
89
89
return self . keys. contains { key in
90
90
key. caseInsensitiveCompare ( headerName) == . orderedSame
91
91
}
92
92
}
93
- }
93
+ }
0 commit comments