Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit a515ee5

Browse files
committed
Merge pull request #189 from Raman148/bugfix/syndication/openurl
Adding Syndication Regex to Bypass openURL
2 parents 86d5c8a + c19e6d1 commit a515ee5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Classes/YTPlayerView.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
NSString static *const kYTPlayerAdUrlRegexPattern = @"^http(s)://pubads.g.doubleclick.net/pagead/conversion/";
6161
NSString static *const kYTPlayerOAuthRegexPattern = @"^http(s)://accounts.google.com/o/oauth2/(.*)$";
6262
NSString static *const kYTPlayerStaticProxyRegexPattern = @"^https://content.googleapis.com/static/proxy.html(.*)$";
63+
NSString static *const kYTPlayerSyndicationRegexPattern = @"^https://tpc.googlesyndication.com/sodar/(.*).html$";
6364

6465
@interface YTPlayerView()
6566

@@ -621,6 +622,16 @@ - (BOOL)handleHttpNavigationToUrl:(NSURL *) url {
621622
[adRegex firstMatchInString:url.absoluteString
622623
options:0
623624
range:NSMakeRange(0, [url.absoluteString length])];
625+
626+
NSRegularExpression *syndicationRegex =
627+
[NSRegularExpression regularExpressionWithPattern:kYTPlayerSyndicationRegexPattern
628+
options:NSRegularExpressionCaseInsensitive
629+
error:&error];
630+
631+
NSTextCheckingResult *syndicationMatch =
632+
[syndicationRegex firstMatchInString:url.absoluteString
633+
options:0
634+
range:NSMakeRange(0, [url.absoluteString length])];
624635

625636
NSRegularExpression *oauthRegex =
626637
[NSRegularExpression regularExpressionWithPattern:kYTPlayerOAuthRegexPattern
@@ -640,7 +651,7 @@ - (BOOL)handleHttpNavigationToUrl:(NSURL *) url {
640651
options:0
641652
range:NSMakeRange(0, [url.absoluteString length])];
642653

643-
if (ytMatch || adMatch || oauthMatch || staticProxyMatch) {
654+
if (ytMatch || adMatch || oauthMatch || staticProxyMatch || syndicationMatch) {
644655
return YES;
645656
} else {
646657
[[UIApplication sharedApplication] openURL:url];

0 commit comments

Comments
 (0)