Skip to content

Commit 0595954

Browse files
authored
Updated according to request
1 parent 685f834 commit 0595954

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Plugin/AbstractPlugin.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ 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-
1613
public function onBeforeRequest(ProxyEvent $event){
1714
// fired right before a request is being sent to a proxy
1815
}
@@ -35,13 +32,16 @@ final public function route(ProxyEvent $event){
3532
$url = $event['request']->getUri();
3633

3734
// url filter provided and current request url does not match it
38-
if($this->url_pattern && strpos($url, $this->url_pattern) === false){
39-
return;
40-
}
41-
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;
35+
if($this->url_pattern){
36+
if(strpos($this->url_pattern, '/') === 0){
37+
if(!preg_match($this->url_pattern, $url))
38+
return;
39+
}
40+
else
41+
{
42+
if(stripos($url, $this->url_pattern) === false)
43+
return;
44+
}
4545
}
4646

4747
switch($event->getName()){

0 commit comments

Comments
 (0)