Skip to content

Commit 09e49e8

Browse files
authored
Allow for pasteboard links with trailing slashes as valid custom domain links (#2220)
* Allow for pasteboard links with trailing slashes as valid custom domain links.
1 parent a3dfe08 commit 09e49e8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Example/DynamicLinks/FDLBuilderTestAppObjC/ViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ - (void)_buildFDLLink {
290290
NSURL *link = [NSURL URLWithString:_paramValues[@"linkString"]];
291291
FIRDynamicLinkComponents *components =
292292
[FIRDynamicLinkComponents componentsWithLink:link
293-
domainURIPrefix:_paramValues[@"https://domain"]];
293+
domainURIPrefix:_paramValues[@"domainURIPrefix"]];
294294

295295
FIRDynamicLinkGoogleAnalyticsParameters *analyticsParams =
296296
[FIRDynamicLinkGoogleAnalyticsParameters

Example/DynamicLinks/Tests/FIRDynamicLinksTest.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,12 @@ - (void)testValidCustomDomainNames {
10321032
@"https://a.firebase.com/mypath/mylink", // Short FDL starting https://a.firebase.com/mypath
10331033
@"https://a.firebase.com/mypath?link=abcd&test=1", // Long FDL starting with
10341034
// https://a.firebase.com/mypath
1035+
@"https://a.firebase.com/mypath/?link=https://www.google.com&test=1" // Long FDL coming from
1036+
// the app preview page.
1037+
// Note that the long FDL
1038+
// coming from the
1039+
// pasteboard has an extra
1040+
// trailing slash.
10351041
];
10361042

10371043
for (NSString *urlString in urlStrings) {

Firebase/DynamicLinks/Utilities/FDLUtilities.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ BOOL FIRDLIsURLForWhiteListedCustomDomain(NSURL *_Nullable URL) {
212212
([urlStr characterAtIndex:domainURIPrefixStr.length] == '/' ||
213213
[urlStr characterAtIndex:domainURIPrefixStr.length] == '?')) {
214214
// Check if there are any more '/' after the first '/' or '?' trailing the
215-
// domainURIPrefix.
215+
// domainURIPrefix. This does not apply to unique match links copied from the clipboard.
216+
// The clipboard links will have '?link=' after the domainURIPrefix.
216217
NSString *urlWithoutDomainURIPrefix =
217218
[urlStr substringFromIndex:domainURIPrefixStr.length + 1];
218-
if ([urlWithoutDomainURIPrefix rangeOfString:@"/"].location == NSNotFound) {
219+
if ([urlWithoutDomainURIPrefix rangeOfString:@"/"].location == NSNotFound ||
220+
[urlWithoutDomainURIPrefix rangeOfString:@"?link="].location != NSNotFound) {
219221
customDomainMatchFound = true;
220222
break;
221223
}

0 commit comments

Comments
 (0)