File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 77
88#import < Foundation/Foundation.h>
99
10- #define kCustomProtocolScheme @" https"
11- #define kQueueHasMessage @" __wvjb_queue_message__"
12- #define kBridgeLoaded @" __bridge_loaded__"
10+ #define kOldProtocolScheme @" wvjbscheme"
11+ #define kNewProtocolScheme @" https"
12+ #define kQueueHasMessage @" __wvjb_queue_message__"
13+ #define kBridgeLoaded @" __bridge_loaded__"
1314
1415typedef void (^WVJBResponseCallback)(id responseData);
1516typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
Original file line number Diff line number Diff line change @@ -123,22 +123,25 @@ - (void)injectJavascriptFile {
123123}
124124
125125- (BOOL )isWebViewJavascriptBridgeURL : (NSURL *)url {
126- if (![[url scheme ] isEqualToString: kCustomProtocolScheme ]) {
126+ if (![self isSchemeMatch: url]) {
127127 return NO ;
128128 }
129- return ([self isBridgeLoadedURL: url] || [self isQueueMessageURL: url]);
129+ return [self isBridgeLoadedURL: url] || [self isQueueMessageURL: url];
130+ }
131+
132+ - (BOOL )isSchemeMatch : (NSURL *)url {
133+ NSString * scheme = url.scheme .lowercaseString ;
134+ return [scheme isEqualToString: kNewProtocolScheme ] || [scheme isEqualToString: kOldProtocolScheme ];
130135}
131136
132137- (BOOL )isQueueMessageURL : (NSURL *)url {
133- if ([[url host ] isEqualToString: kQueueHasMessage ]){
134- return YES ;
135- } else {
136- return NO ;
137- }
138+ NSString * host = url.host .lowercaseString ;
139+ return [self isSchemeMatch: url] && [host isEqualToString: kQueueHasMessage ];
138140}
139141
140142- (BOOL )isBridgeLoadedURL : (NSURL *)url {
141- return ([[url scheme ] isEqualToString: kCustomProtocolScheme ] && [[url host ] isEqualToString: kBridgeLoaded ]);
143+ NSString * host = url.host .lowercaseString ;
144+ return [self isSchemeMatch: url] && [host isEqualToString: kBridgeLoaded ];
142145}
143146
144147- (void )logUnkownMessage : (NSURL *)url {
You can’t perform that action at this time.
0 commit comments