mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 23:23:42 -06:00
Fixed the way ShortUrlIdentifier is created from requests, on different request scopes
This commit is contained in:
parent
327d35fe57
commit
fd82de31c0
@ -45,8 +45,8 @@ abstract class AbstractTrackingAction implements MiddlewareInterface
|
|||||||
|
|
||||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
{
|
{
|
||||||
$shortCode = $request->getAttribute('shortCode', '');
|
$identifier = ShortUrlIdentifier::fromRedirectRequest($request);
|
||||||
$identifier = ShortUrlIdentifier::fromRequest($request);
|
$shortCode = $identifier->shortCode();
|
||||||
$query = $request->getQueryParams();
|
$query = $request->getQueryParams();
|
||||||
$disableTrackParam = $this->appOptions->getDisableTrackParam();
|
$disableTrackParam = $this->appOptions->getDisableTrackParam();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class QrCodeAction implements MiddlewareInterface
|
|||||||
|
|
||||||
public function process(Request $request, RequestHandlerInterface $handler): Response
|
public function process(Request $request, RequestHandlerInterface $handler): Response
|
||||||
{
|
{
|
||||||
$identifier = ShortUrlIdentifier::fromRequest($request);
|
$identifier = ShortUrlIdentifier::fromRedirectRequest($request);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->urlResolver->resolveEnabledShortUrl($identifier);
|
$this->urlResolver->resolveEnabledShortUrl($identifier);
|
||||||
|
@ -18,7 +18,7 @@ final class ShortUrlIdentifier
|
|||||||
$this->domain = $domain;
|
$this->domain = $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromRequest(ServerRequestInterface $request): self
|
public static function fromApiRequest(ServerRequestInterface $request): self
|
||||||
{
|
{
|
||||||
$shortCode = $request->getAttribute('shortCode', '');
|
$shortCode = $request->getAttribute('shortCode', '');
|
||||||
$domain = $request->getQueryParams()['domain'] ?? null;
|
$domain = $request->getQueryParams()['domain'] ?? null;
|
||||||
@ -26,6 +26,14 @@ final class ShortUrlIdentifier
|
|||||||
return new self($shortCode, $domain);
|
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
|
public static function fromCli(InputInterface $input): self
|
||||||
{
|
{
|
||||||
$shortCode = $input->getArgument('shortCode');
|
$shortCode = $input->getArgument('shortCode');
|
||||||
|
@ -34,7 +34,7 @@ class ResolveShortUrlAction extends AbstractRestAction
|
|||||||
public function handle(Request $request): Response
|
public function handle(Request $request): Response
|
||||||
{
|
{
|
||||||
$transformer = new ShortUrlDataTransformer($this->domainConfig);
|
$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));
|
return new JsonResponse($transformer->transform($url));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user