mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Added forwardQuery property in short URLs, that determines if the query should be forwarded to the long URL
This commit is contained in:
@@ -100,4 +100,9 @@ return static function (ClassMetadata $metadata, array $emConfig): void {
|
||||
->columnName('crawlable')
|
||||
->option('default', false)
|
||||
->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 bool $titleWasAutoResolved = false;
|
||||
private bool $crawlable = false;
|
||||
private bool $forwardQuery = true;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
@@ -207,6 +208,11 @@ class ShortUrl extends AbstractEntity
|
||||
return $this->crawlable;
|
||||
}
|
||||
|
||||
public function forwardQuery(): bool
|
||||
{
|
||||
return $this->forwardQuery;
|
||||
}
|
||||
|
||||
public function update(
|
||||
ShortUrlEdit $shortUrlEdit,
|
||||
?ShortUrlRelationResolverInterface $relationResolver = null,
|
||||
|
||||
@@ -21,9 +21,10 @@ class ShortUrlRedirectionBuilder implements ShortUrlRedirectionBuilderInterface
|
||||
public function buildShortUrlRedirect(ShortUrl $shortUrl, array $currentQuery, ?string $extraPath = null): string
|
||||
{
|
||||
$uri = Uri::createFromString($shortUrl->getLongUrl());
|
||||
$shouldForwardQuery = $shortUrl->forwardQuery();
|
||||
|
||||
return $uri
|
||||
->withQuery($this->resolveQuery($uri, $currentQuery))
|
||||
->withQuery($shouldForwardQuery ? $this->resolveQuery($uri, $currentQuery) : $uri->getQuery())
|
||||
->withPath($this->resolvePath($uri, $extraPath))
|
||||
->__toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user