@@ -609,14 +609,9 @@ - (void)genericHTTPRequest:(NSURLRequest *)request
609609
610610 if (Branch.trackingDisabled ) {
611611 NSString *endpoint = request.URL .absoluteString ;
612- BNCPreferenceHelper *prefs = [BNCPreferenceHelper preferenceHelper ];
613- if (([endpoint bnc_containsString: @" /v1/install" ] ||
614- [endpoint bnc_containsString: @" /v1/open" ]) &&
615- ((prefs.linkClickIdentifier .length > 0 ) ||
616- (prefs.spotlightIdentifier .length > 0 ) ||
617- (prefs.universalLinkUrl .length > 0 ))) {
618- // Allow this network operation since it's an open/install to resolve a link.
619- } else {
612+
613+ // if endpoint is not on the whitelist, fail it.
614+ if (![self whiteListContainsEndpoint: endpoint]) {
620615 [[BNCPreferenceHelper preferenceHelper ] clearTrackingInformation ];
621616 NSError *error = [NSError branchErrorWithCode: BNCTrackingDisabledError];
622617 BNCLogError (@" Network service error: %@ ." , error);
@@ -626,6 +621,7 @@ - (void)genericHTTPRequest:(NSURLRequest *)request
626621 return ;
627622 }
628623 }
624+
629625 id <BNCNetworkOperationProtocol> operation =
630626 [self .networkService networkOperationWithURLRequest: request.copy completion: completionHandler];
631627 [operation start ];
@@ -639,6 +635,28 @@ - (void)genericHTTPRequest:(NSURLRequest *)request
639635 }
640636}
641637
638+ - (BOOL )whiteListContainsEndpoint : (NSString *)endpoint {
639+ BNCPreferenceHelper *prefs = [BNCPreferenceHelper preferenceHelper ];
640+ BOOL hasIdentifier = (prefs.linkClickIdentifier .length > 0 ) || (prefs.spotlightIdentifier .length > 0 ) || (prefs.universalLinkUrl .length > 0 );
641+
642+ // Allow install to resolve a link.
643+ if ([endpoint bnc_containsString: @" /v1/install" ] && hasIdentifier) {
644+ return YES ;
645+ }
646+
647+ // Allow open to resolve a link.
648+ if ([endpoint bnc_containsString: @" /v1/open" ] && hasIdentifier) {
649+ return YES ;
650+ }
651+
652+ // Allow short url creation requests
653+ if ([endpoint bnc_containsString: @" /v1/url" ]) {
654+ return YES ;
655+ }
656+
657+ return NO ;
658+ }
659+
642660- (NSError *) verifyNetworkOperation : (id <BNCNetworkOperationProtocol>)operation {
643661
644662 if (!operation) {
0 commit comments