Skip to content

Commit

Permalink
isMatchingDomain method added
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfyakov21 committed Jun 28, 2022
1 parent 7473071 commit c51f2d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 0 additions & 4 deletions macos/RNCookieManagerMacOs/RNCookieManagerMacOs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
* LICENSE file here: https://github.com/joeferraro/react-native-cookies/blob/master/LICENSE.md.
*/

#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

#import <WebKit/WebKit.h>

Expand Down
14 changes: 10 additions & 4 deletions macos/RNCookieManagerMacOs/RNCookieManagerMacOs.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
*/

#import "RNCookieManagerMacOS.h"
#if __has_include("RCTConvert.h")
#import "RCTConvert.h"
#else
#import <React/RCTConvert.h>
#endif

static NSString * const NOT_AVAILABLE_ERROR_MESSAGE = @"WebKit/WebKit-Components are only available with macOS 10.2 and higher!";
static NSString * const INVALID_URL_MISSING_HTTP = @"Invalid URL: It may be missing a protocol (ex. http:// or https://).";
Expand Down Expand Up @@ -340,4 +336,14 @@ -(NSDictionary *)createCookieData:(NSHTTPCookie *)cookie
return cookieData;
}

-(BOOL)isMatchingDomain:(NSString *)originDomain
cookieDomain:(NSString *)cookieDomain
{
if ([originDomain isEqualToString: cookieDomain]) {
return @YES;
}
NSString *parentDomain = [cookieDomain hasPrefix:@"."] ? cookieDomain : [@"." stringByAppendingString: cookieDomain];
return [originDomain hasSuffix:parentDomain];
}

@end

0 comments on commit c51f2d3

Please sign in to comment.