Skip to content

Commit 685f834

Browse files
authored
Support url_pattern_regex
Useful to create a plugin that handles more websites (i.e abc.com, abc.de, abc.eu, etc) or similar.
1 parent 1e5a93a commit 685f834

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Plugin/AbstractPlugin.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ abstract class AbstractPlugin implements EventSubscriberInterface {
1010
// apply these methods only to those events whose request URL passes this filter
1111
protected $url_pattern;
1212

13+
// apply these methods only to those events whose request URL passes this filter (regex)
14+
protected $url_pattern_regex;
15+
1316
public function onBeforeRequest(ProxyEvent $event){
1417
// fired right before a request is being sent to a proxy
1518
}
@@ -36,6 +39,11 @@ final public function route(ProxyEvent $event){
3639
return;
3740
}
3841

42+
// url filter (regex) provided and current request url does not match it
43+
if($this->url_pattern_regex && !preg_match($this->url_pattern_regex, $url)){
44+
return;
45+
}
46+
3947
switch($event->getName()){
4048

4149
case 'request.before_send':
@@ -66,4 +74,4 @@ final public static function getSubscribedEvents(){
6674
}
6775
}
6876

69-
?>
77+
?>

0 commit comments

Comments
 (0)