Skip to content

Commit 669ca47

Browse files
committed
Change the timing of filtering the hostname of the proxy URL to ProxyUrl::getHost() #11
1 parent a0596b8 commit 669ca47

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/ProxyUrl/ProxyUrl.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,22 @@ class ProxyUrl implements EntityInterface, IdentifiableInterface
5252
private $port;
5353

5454
/**
55-
* @param int|string $id
56-
* @param string $target
57-
* @param string $path
58-
* @param string $host
59-
* @param string $scheme
60-
* @param int $port
55+
* @var ProxyHostFilterInterface
56+
*
57+
* @since Property available since Release 1.2.0
58+
*/
59+
private $proxyHostFilter;
60+
61+
/**
62+
* @param int|string $id
63+
* @param string $target
64+
* @param string $path
65+
* @param string $host
66+
* @param string $scheme
67+
* @param int $port
68+
* @param ProxyHostFilterInterface $proxyHostFilter
6169
*/
62-
public function __construct($id, $target, $path, $host, $scheme, $port)
70+
public function __construct($id, $target, $path, $host, $scheme, $port, ProxyHostFilterInterface $proxyHostFilter = null)
6371
{
6472
$this->id = $id;
6573
$this->target = $target;
@@ -81,14 +89,20 @@ public function __construct($id, $target, $path, $host, $scheme, $port)
8189
} else {
8290
$this->port = $port;
8391
}
92+
93+
$this->proxyHostFilter = $proxyHostFilter;
8494
}
8595

8696
/**
8797
* @return string
8898
*/
8999
public function getHost()
90100
{
91-
return $this->host;
101+
if ($this->proxyHostFilter === null) {
102+
return $this->host;
103+
} else {
104+
return $this->proxyHostFilter->filter($this->host);
105+
}
92106
}
93107

94108
/**

src/ProxyUrl/ProxyUrlFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ public function create($proxyUrlId, $path, $proxyUrl, ProxyHostFilterInterface $
2828
{
2929
list($proxyUrlPath, $proxyUrlHost, $proxyUrlScheme, $proxyUrlPort) = static::parseUrl($proxyUrl);
3030

31-
if ($proxyHostFilter !== null) {
32-
$proxyUrlHost = $proxyHostFilter->filter($proxyUrlHost);
33-
}
34-
35-
return new ProxyUrl($proxyUrlId, $path, $proxyUrlPath, $proxyUrlHost, $proxyUrlScheme, $proxyUrlPort);
31+
return new ProxyUrl($proxyUrlId, $path, $proxyUrlPath, $proxyUrlHost, $proxyUrlScheme, $proxyUrlPort, $proxyHostFilter);
3632
}
3733

3834
/**

0 commit comments

Comments
 (0)