Ensured domain is taken into account when generating QR codes

This commit is contained in:
Alejandro Celaya 2019-10-22 19:43:53 +02:00
parent 6d366188c9
commit cd6f067fe5
2 changed files with 4 additions and 1 deletions

View File

@ -59,8 +59,10 @@ class QrCodeAction implements MiddlewareInterface
{
// Make sure the short URL exists for this short code
$shortCode = $request->getAttribute('shortCode');
$domain = $request->getUri()->getAuthority();
try {
$this->urlShortener->shortCodeToUrl($shortCode);
$this->urlShortener->shortCodeToUrl($shortCode, $domain);
} catch (InvalidShortCodeException | EntityDoesNotExistException $e) {
$this->logger->warning('An error occurred while creating QR code. {e}', ['e' => $e]);
return $this->buildErrorResponse($request, $handler);

View File

@ -152,6 +152,7 @@ class UrlShortener implements UrlShortenerInterface
if ($shortUrl === null) {
throw EntityDoesNotExistException::createFromEntityAndConditions(ShortUrl::class, [
'shortCode' => $shortCode,
'domain' => $domain,
]);
}