@@ -1015,6 +1015,63 @@ - (void)testSelfDiagnoseCompletionCalled {
10151015 [self waitForExpectationsWithTimeout: 2.0 handler: nil ];
10161016}
10171017
1018+ #pragma mark - Custom domain tests
1019+ - (void )testValidCustomDomainNames {
1020+ // Entries in plist file:
1021+ // https://google.com
1022+ // g.co
1023+ // https://g.co
1024+ // https://google.com/one
1025+ // https://a.firebase.com/mypath
1026+
1027+ [FIRApp configure ];
1028+ NSArray <NSString *> *urlStrings = @[
1029+ @" https://google.com/1" , // Valid domain. Any path.
1030+ @" https://google.com/2" , // Valid domain. Any path.
1031+ @" https://google.com/one" , // Valid domain. Specified path.
1032+ @" https://g.co/1" , // Valid domain. Any path.
1033+ @" https://a.firebase.com/mypath/" ,// Valid subdomain.
1034+ @" https://a.firebase.com/mypath/abcd/efgh" ,// Long path.
1035+ ];
1036+
1037+ for (NSString *urlString in urlStrings) {
1038+ NSURL *url = [NSURL URLWithString: urlString];
1039+ BOOL matchesShortLinkFormat = [self .service matchesShortLinkFormat: url];
1040+
1041+ XCTAssertTrue (matchesShortLinkFormat,
1042+ @" Non-DDL domain URL matched short link format with URL: %@ " , url);
1043+ }
1044+ }
1045+
1046+ - (void )testInvalidCustomDomainNames {
1047+ // Entries in plist file:
1048+ // https://google.com
1049+ // g.co
1050+ // https://g.co
1051+ // https://google.com/one
1052+ // https://a.firebase.com/mypath
1053+
1054+ [FIRApp configure ];
1055+ NSArray <NSString *> *urlStrings = @[
1056+ @" mydomain.com" , // Domain not in plist. Also, no scheme.
1057+ @" http://mydomain" , // Domain not in plist. No path.
1058+ @" google.com" , // Valid domain. No scheme.
1059+ @" https://google.com" , // Valid domain. No path.
1060+ @" http://google.com" , // Valid domain. Invalid scheme.
1061+ @" https://g.co.com/abc" , // Invalid domain starts with valid domain.
1062+ @" https://firebase.com/mypath" , // Invalid (sub)domain.
1063+ @" https://b.firebase.com/mypath" // Invalid subdomain.
1064+ ];
1065+
1066+ for (NSString *urlString in urlStrings) {
1067+ NSURL *url = [NSURL URLWithString: urlString];
1068+ BOOL matchesShortLinkFormat = [self .service matchesShortLinkFormat: url];
1069+
1070+ XCTAssertFalse (matchesShortLinkFormat,
1071+ @" Non-DDL domain URL matched short link format with URL: %@ " , url);
1072+ }
1073+ }
1074+
10181075#pragma mark - Private Helpers
10191076
10201077- (void )removeAllFIRApps {
0 commit comments