Bläddra i källkod

Fixing the short url logic (#9005)

* Adding back the missed regex check for short links and correcting the test cases.
Eldhose M Babu 4 år sedan
förälder
incheckning
276e35f17f

+ 5 - 1
FirebaseDynamicLinks/Sources/Utilities/FDLUtilities.m

@@ -295,7 +295,11 @@ BOOL FIRDLMatchesShortLinkFormat(NSURL *URL) {
   // Path cannot be prefixed with /link/dismiss
   BOOL isDismiss = [[URL.path lowercaseString] hasPrefix:@"/link/dismiss"];
 
-  return hasPathOrCustomDomain && !isDismiss && canParse;
+  // Checks short link format by having only one path after domain prefix.
+  BOOL matchesRegularExpression =
+      ([URL.path rangeOfString:@"/[^/]+" options:NSRegularExpressionSearch].location != NSNotFound);
+
+  return hasPathOrCustomDomain && !isDismiss && canParse && matchesRegularExpression;
 }
 
 NSString *FIRDLMatchTypeStringFromServerString(NSString *_Nullable serverMatchTypeString) {

+ 0 - 2
FirebaseDynamicLinks/Tests/Unit/FIRDynamicLinksTest.m

@@ -1198,7 +1198,6 @@ static NSString *const kInfoPlistCustomDomainsKey = @"FirebaseDynamicLinksCustom
 - (void)testPassMatchesShortLinkFormatForCustomDomains {
   NSArray<NSString *> *urlStrings = @[
     @"https://google.com/xyz", @"https://google.com/xyz/?link=https://somedomain",
-    @"https://google.com?link=https://somedomain", @"https://google.com/?link=https://somedomain",
     @"https://google.com/xyz?link=https://somedomain",
     @"https://google.com/xyz/?link=https://somedomain", @"https://google.com/one/xyz",
     @"https://google.com/one/xyz?link=https://somedomain",
@@ -1606,7 +1605,6 @@ static NSString *const kInfoPlistCustomDomainsKey = @"FirebaseDynamicLinksCustom
     @"https://google.com/one?",               // Short FDL starting with 'https://google.com'
     @"https://google.com/one/mylink",         // Short FDL starting with  'https://google.com/one'
     @"https://a.firebase.com/mypath/mylink",  // Short FDL starting https://a.firebase.com/mypath
-    @"https://google.com?link=https://somedomain", @"https://google.com/?link=https://somedomain",
     @"https://google.com/somepath?link=https://somedomain",
     @"https://google.com/somepath/?link=https://somedomain",
     @"https://google.com/somepath/somepath2?link=https://somedomain",