File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1313#endif
1414
1515static NSString * const NOT_AVAILABLE_ERROR_MESSAGE = @" WebKit/WebKit-Components are only available with iOS11 and higher!" ;
16+ static NSString * const INVALID_URL_MISSING_HTTP = @" Invalid URL: It may be missing a protocol (ex. http:// or https://)." ;
1617
1718@implementation RNCookieManagerIOS
1819
@@ -109,6 +110,11 @@ -(NSString *)getDomainName:(NSURL *) url
109110 NSInteger maxLength = 2 ;
110111
111112 NSURLComponents *components = [[NSURLComponents alloc ]initWithURL:url resolvingAgainstBaseURL: FALSE ];
113+
114+ if ([components.host isEqual: @" " ] || components.host == nil ) {
115+ return nil ;
116+ }
117+
112118 NSArray <NSString *> *separatedHost = [components.host componentsSeparatedByString: separator];
113119 NSInteger count = [separatedHost count ];
114120 NSInteger endPosition = count;
@@ -133,6 +139,11 @@ -(NSString *)getDomainName:(NSURL *) url
133139 dispatch_async (dispatch_get_main_queue (), ^(){
134140 NSString *topLevelDomain = [self getDomainName: url];
135141
142+ if (topLevelDomain == nil ) {
143+ reject (@" " , INVALID_URL_MISSING_HTTP, nil );
144+ return ;
145+ }
146+
136147 WKHTTPCookieStore *cookieStore = [[WKWebsiteDataStore defaultDataStore ] httpCookieStore ];
137148 [cookieStore getAllCookies: ^(NSArray <NSHTTPCookie *> *allCookies) {
138149 NSMutableDictionary *cookies = [NSMutableDictionary dictionary ];
You can’t perform that action at this time.
0 commit comments