mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Added forwardQuery property in short URLs, that determines if the query should be forwarded to the long URL
This commit is contained in:
parent
60c8f23a63
commit
1ed6458b39
26
data/migrations/Version20211002072605.php
Normal file
26
data/migrations/Version20211002072605.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace ShlinkMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20211002072605 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$shortUrls = $schema->getTable('short_urls');
|
||||||
|
$this->skipIf($shortUrls->hasColumn('forward_query'));
|
||||||
|
$shortUrls->addColumn('forward_query', Types::BOOLEAN, ['default' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$shortUrls = $schema->getTable('short_urls');
|
||||||
|
$this->skipIf(! $shortUrls->hasColumn('forward_query'));
|
||||||
|
$shortUrls->dropColumn('forward_query');
|
||||||
|
}
|
||||||
|
}
|
@ -100,4 +100,9 @@ return static function (ClassMetadata $metadata, array $emConfig): void {
|
|||||||
->columnName('crawlable')
|
->columnName('crawlable')
|
||||||
->option('default', false)
|
->option('default', false)
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
|
$builder->createField('forwardQuery', Types::BOOLEAN)
|
||||||
|
->columnName('forward_query')
|
||||||
|
->option('default', true)
|
||||||
|
->build();
|
||||||
};
|
};
|
||||||
|
@ -43,6 +43,7 @@ class ShortUrl extends AbstractEntity
|
|||||||
private ?string $title = null;
|
private ?string $title = null;
|
||||||
private bool $titleWasAutoResolved = false;
|
private bool $titleWasAutoResolved = false;
|
||||||
private bool $crawlable = false;
|
private bool $crawlable = false;
|
||||||
|
private bool $forwardQuery = true;
|
||||||
|
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
@ -207,6 +208,11 @@ class ShortUrl extends AbstractEntity
|
|||||||
return $this->crawlable;
|
return $this->crawlable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function forwardQuery(): bool
|
||||||
|
{
|
||||||
|
return $this->forwardQuery;
|
||||||
|
}
|
||||||
|
|
||||||
public function update(
|
public function update(
|
||||||
ShortUrlEdit $shortUrlEdit,
|
ShortUrlEdit $shortUrlEdit,
|
||||||
?ShortUrlRelationResolverInterface $relationResolver = null,
|
?ShortUrlRelationResolverInterface $relationResolver = null,
|
||||||
|
@ -21,9 +21,10 @@ class ShortUrlRedirectionBuilder implements ShortUrlRedirectionBuilderInterface
|
|||||||
public function buildShortUrlRedirect(ShortUrl $shortUrl, array $currentQuery, ?string $extraPath = null): string
|
public function buildShortUrlRedirect(ShortUrl $shortUrl, array $currentQuery, ?string $extraPath = null): string
|
||||||
{
|
{
|
||||||
$uri = Uri::createFromString($shortUrl->getLongUrl());
|
$uri = Uri::createFromString($shortUrl->getLongUrl());
|
||||||
|
$shouldForwardQuery = $shortUrl->forwardQuery();
|
||||||
|
|
||||||
return $uri
|
return $uri
|
||||||
->withQuery($this->resolveQuery($uri, $currentQuery))
|
->withQuery($shouldForwardQuery ? $this->resolveQuery($uri, $currentQuery) : $uri->getQuery())
|
||||||
->withPath($this->resolvePath($uri, $extraPath))
|
->withPath($this->resolvePath($uri, $extraPath))
|
||||||
->__toString();
|
->__toString();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user