mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Make sure short URL domain is resolved as null when default one is provided
This commit is contained in:
@@ -31,7 +31,6 @@ class CreateShortUrlCommand extends Command
|
||||
public const NAME = 'short-url:create';
|
||||
|
||||
private ?SymfonyStyle $io;
|
||||
private string $defaultDomain;
|
||||
|
||||
public function __construct(
|
||||
private readonly UrlShortenerInterface $urlShortener,
|
||||
@@ -39,7 +38,6 @@ class CreateShortUrlCommand extends Command
|
||||
private readonly UrlShortenerOptions $options,
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->defaultDomain = $this->options->domain['hostname'] ?? '';
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
@@ -121,7 +119,6 @@ class CreateShortUrlCommand extends Command
|
||||
protected function interact(InputInterface $input, OutputInterface $output): void
|
||||
{
|
||||
$this->verifyLongUrlArgument($input, $output);
|
||||
$this->verifyDomainArgument($input);
|
||||
}
|
||||
|
||||
private function verifyLongUrlArgument(InputInterface $input, OutputInterface $output): void
|
||||
@@ -138,12 +135,6 @@ class CreateShortUrlCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function verifyDomainArgument(InputInterface $input): void
|
||||
{
|
||||
$domain = $input->getOption('domain');
|
||||
$input->setOption('domain', $domain === $this->defaultDomain ? null : $domain);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int
|
||||
{
|
||||
$io = $this->getIO($input, $output);
|
||||
|
||||
@@ -28,8 +28,6 @@ class CreateShortUrlCommandTest extends TestCase
|
||||
{
|
||||
use CliTestUtilsTrait;
|
||||
|
||||
private const DEFAULT_DOMAIN = 'default.com';
|
||||
|
||||
private CommandTester $commandTester;
|
||||
private MockObject & UrlShortenerInterface $urlShortener;
|
||||
private MockObject & ShortUrlStringifierInterface $stringifier;
|
||||
@@ -43,7 +41,7 @@ class CreateShortUrlCommandTest extends TestCase
|
||||
$this->urlShortener,
|
||||
$this->stringifier,
|
||||
new UrlShortenerOptions(
|
||||
domain: ['hostname' => self::DEFAULT_DOMAIN, 'schema' => ''],
|
||||
domain: ['hostname' => 'example.com', 'schema' => ''],
|
||||
defaultShortCodesLength: 5,
|
||||
),
|
||||
);
|
||||
@@ -147,9 +145,8 @@ class CreateShortUrlCommandTest extends TestCase
|
||||
public static function provideDomains(): iterable
|
||||
{
|
||||
yield 'no domain' => [[], null];
|
||||
yield 'non-default domain foo' => [['--domain' => 'foo.com'], 'foo.com'];
|
||||
yield 'non-default domain bar' => [['-d' => 'bar.com'], 'bar.com'];
|
||||
yield 'default domain' => [['--domain' => self::DEFAULT_DOMAIN], null];
|
||||
yield 'domain foo' => [['--domain' => 'foo.com'], 'foo.com'];
|
||||
yield 'domain bar' => [['-d' => 'bar.com'], 'bar.com'];
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideFlags')]
|
||||
|
||||
Reference in New Issue
Block a user