Skip to content

Commit

Permalink
Add Possibility to reset requestMatchers
Browse files Browse the repository at this point in the history
  • Loading branch information
hons82 committed Aug 27, 2014
1 parent 4f5f13c commit f71a8e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions WebViewProxy/WebViewProxy.h
Expand Up @@ -38,6 +38,7 @@ typedef void (^StopLoadingHandler)();
// The actual WebViewProxy API itself
typedef void (^WVPHandler)(NSURLRequest* req, WVPResponse* res);
@interface WebViewProxy : NSObject
+ (void) resetRequestMatchers;
+ (void) handleRequestsWithScheme:(NSString*)scheme handler:(WVPHandler)handler;
+ (void) handleRequestsWithHost:(NSString*)host handler:(WVPHandler)handler;
+ (void) handleRequestsWithHost:(NSString*)host path:(NSString*)path handler:(WVPHandler)handler;
Expand Down
5 changes: 4 additions & 1 deletion WebViewProxy/WebViewProxy.m
Expand Up @@ -272,12 +272,15 @@ + (void)load {
#endif
}
+ (void)initialize {
requestMatchers = [NSMutableArray array];
[WebViewProxy resetRequestMatchers];
webViewUserAgentTest = [NSPredicate predicateWithFormat:@"self MATCHES '^Mozilla.*Mac OS X.*'"];
webViewProxyLoopDetection = [NSPredicate predicateWithFormat:@"self.fragment MATCHES '__webviewproxyreq__'"];
// e.g. "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A403"
[NSURLProtocol registerClass:[WebViewProxyURLProtocol class]];
}
+ (void)resetRequestMatchers {
requestMatchers = [NSMutableArray array];
}
+ (void)handleRequestsWithScheme:(NSString *)scheme handler:(WVPHandler)handler {
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"scheme MATCHES[cd] %@", scheme];
[self handleRequestsMatching:predicate handler:handler];
Expand Down

0 comments on commit f71a8e0

Please sign in to comment.