File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,9 @@ extension AppEnvironment {
195
195
Environment . get ( " HIDE_STAGING_BANNER " ) . flatMap ( \. asBool)
196
196
?? Constants . defaultHideStagingBanner
197
197
} ,
198
- homepageInterstitial: { Environment . get ( " HOMEPAGE_INTERSTITIAL " ) } ,
198
+ homepageInterstitial: {
199
+ Environment . get ( " HOMEPAGE_INTERSTITIAL " ) . flatMap ( \. trimmed)
200
+ } ,
199
201
httpClient: { httpClient } ,
200
202
loadSPIManifest: { path in SPIManifest . Manifest. load ( in: path) } ,
201
203
logger: { logger } ,
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ extension String {
45
45
}
46
46
47
47
var trimmed : String ? {
48
- let trimmedString = trimmingCharacters ( in: . whitespaces )
48
+ let trimmedString = trimmingCharacters ( in: . whitespacesAndNewlines )
49
49
if trimmedString. isEmpty { return nil }
50
50
return trimmedString
51
51
}
Original file line number Diff line number Diff line change @@ -29,4 +29,29 @@ class AppEnvironmentTests: XCTestCase {
29
29
XCTAssertEqual ( Current . fileManager. checkoutsDirectory ( ) , " /tmp/foo " )
30
30
}
31
31
32
+ func test_homepageInterstitial( ) throws {
33
+ defer { unsetenv ( " HOMEPAGE_INTERSTITIAL " ) }
34
+ Current . homepageInterstitial = AppEnvironment . live. homepageInterstitial
35
+ do {
36
+ unsetenv ( " HOMEPAGE_INTERSTITIAL " )
37
+ XCTAssertEqual ( Current . homepageInterstitial ( ) , nil )
38
+ }
39
+ do {
40
+ setenv ( " HOMEPAGE_INTERSTITIAL " , " foo " , 1 )
41
+ XCTAssertEqual ( Current . homepageInterstitial ( ) , " foo " )
42
+ }
43
+ do {
44
+ setenv ( " HOMEPAGE_INTERSTITIAL " , " " , 1 )
45
+ XCTAssertEqual ( Current . homepageInterstitial ( ) , nil )
46
+ }
47
+ do {
48
+ setenv ( " HOMEPAGE_INTERSTITIAL " , " " , 1 )
49
+ XCTAssertEqual ( Current . homepageInterstitial ( ) , nil )
50
+ }
51
+ do {
52
+ setenv ( " HOMEPAGE_INTERSTITIAL " , " \t \n " , 1 )
53
+ XCTAssertEqual ( Current . homepageInterstitial ( ) , nil )
54
+ }
55
+ }
56
+
32
57
}
You can’t perform that action at this time.
0 commit comments