mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-27 16:26:37 +03:00
Fixed the way ShortUrlIdentifier is created from requests, on different request scopes
This commit is contained in:
parent
327d35fe57
commit
fd82de31c0
4 changed files with 13 additions and 5 deletions
|
@ -45,8 +45,8 @@ abstract class AbstractTrackingAction implements MiddlewareInterface
|
|||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$shortCode = $request->getAttribute('shortCode', '');
|
||||
$identifier = ShortUrlIdentifier::fromRequest($request);
|
||||
$identifier = ShortUrlIdentifier::fromRedirectRequest($request);
|
||||
$shortCode = $identifier->shortCode();
|
||||
$query = $request->getQueryParams();
|
||||
$disableTrackParam = $this->appOptions->getDisableTrackParam();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class QrCodeAction implements MiddlewareInterface
|
|||
|
||||
public function process(Request $request, RequestHandlerInterface $handler): Response
|
||||
{
|
||||
$identifier = ShortUrlIdentifier::fromRequest($request);
|
||||
$identifier = ShortUrlIdentifier::fromRedirectRequest($request);
|
||||
|
||||
try {
|
||||
$this->urlResolver->resolveEnabledShortUrl($identifier);
|
||||
|
|
|
@ -18,7 +18,7 @@ final class ShortUrlIdentifier
|
|||
$this->domain = $domain;
|
||||
}
|
||||
|
||||
public static function fromRequest(ServerRequestInterface $request): self
|
||||
public static function fromApiRequest(ServerRequestInterface $request): self
|
||||
{
|
||||
$shortCode = $request->getAttribute('shortCode', '');
|
||||
$domain = $request->getQueryParams()['domain'] ?? null;
|
||||
|
@ -26,6 +26,14 @@ final class ShortUrlIdentifier
|
|||
return new self($shortCode, $domain);
|
||||
}
|
||||
|
||||
public static function fromRedirectRequest(ServerRequestInterface $request): self
|
||||
{
|
||||
$shortCode = $request->getAttribute('shortCode', '');
|
||||
$domain = $request->getUri()->getAuthority();
|
||||
|
||||
return new self($shortCode, $domain);
|
||||
}
|
||||
|
||||
public static function fromCli(InputInterface $input): self
|
||||
{
|
||||
$shortCode = $input->getArgument('shortCode');
|
||||
|
|
|
@ -34,7 +34,7 @@ class ResolveShortUrlAction extends AbstractRestAction
|
|||
public function handle(Request $request): Response
|
||||
{
|
||||
$transformer = new ShortUrlDataTransformer($this->domainConfig);
|
||||
$url = $this->urlResolver->resolveShortUrl(ShortUrlIdentifier::fromRequest($request));
|
||||
$url = $this->urlResolver->resolveShortUrl(ShortUrlIdentifier::fromApiRequest($request));
|
||||
|
||||
return new JsonResponse($transformer->transform($url));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue