Skip to content

Commit

Permalink
Merge pull request #189 from Raman148/bugfix/syndication/openurl
Browse files Browse the repository at this point in the history
Adding Syndication Regex to Bypass openURL
  • Loading branch information
ulukaya committed Mar 29, 2016
2 parents 86d5c8a + c19e6d1 commit a515ee5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Classes/YTPlayerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
NSString static *const kYTPlayerAdUrlRegexPattern = @"^http(s)://pubads.g.doubleclick.net/pagead/conversion/";
NSString static *const kYTPlayerOAuthRegexPattern = @"^http(s)://accounts.google.com/o/oauth2/(.*)$";
NSString static *const kYTPlayerStaticProxyRegexPattern = @"^https://content.googleapis.com/static/proxy.html(.*)$";
NSString static *const kYTPlayerSyndicationRegexPattern = @"^https://tpc.googlesyndication.com/sodar/(.*).html$";

@interface YTPlayerView()

Expand Down Expand Up @@ -621,6 +622,16 @@ - (BOOL)handleHttpNavigationToUrl:(NSURL *) url {
[adRegex firstMatchInString:url.absoluteString
options:0
range:NSMakeRange(0, [url.absoluteString length])];

NSRegularExpression *syndicationRegex =
[NSRegularExpression regularExpressionWithPattern:kYTPlayerSyndicationRegexPattern
options:NSRegularExpressionCaseInsensitive
error:&error];

NSTextCheckingResult *syndicationMatch =
[syndicationRegex firstMatchInString:url.absoluteString
options:0
range:NSMakeRange(0, [url.absoluteString length])];

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

if (ytMatch || adMatch || oauthMatch || staticProxyMatch) {
if (ytMatch || adMatch || oauthMatch || staticProxyMatch || syndicationMatch) {
return YES;
} else {
[[UIApplication sharedApplication] openURL:url];
Expand Down

0 comments on commit a515ee5

Please sign in to comment.