mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Ensured base path is honored when stringifying short URLs with a custom domain
This commit is contained in:
@@ -7,13 +7,17 @@ namespace Shlinkio\Shlink\Core\ShortUrl\Helper;
|
||||
use Laminas\Diactoros\Uri;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class ShortUrlStringifier implements ShortUrlStringifierInterface
|
||||
{
|
||||
private array $domainConfig;
|
||||
private string $basePath;
|
||||
|
||||
public function __construct(array $domainConfig)
|
||||
public function __construct(array $domainConfig, string $basePath = '')
|
||||
{
|
||||
$this->domainConfig = $domainConfig;
|
||||
$this->basePath = $basePath;
|
||||
}
|
||||
|
||||
public function stringify(ShortUrl $shortUrl): string
|
||||
@@ -31,6 +35,6 @@ class ShortUrlStringifier implements ShortUrlStringifierInterface
|
||||
return $this->domainConfig['hostname'] ?? '';
|
||||
}
|
||||
|
||||
return $domain->getAuthority();
|
||||
return sprintf('%s%s', $domain->getAuthority(), $this->basePath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user