From cd6f067fe579ba00601bc3650c6003a6e41d0641 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 22 Oct 2019 19:43:53 +0200 Subject: [PATCH] Ensured domain is taken into account when generating QR codes --- module/Core/src/Action/QrCodeAction.php | 4 +++- module/Core/src/Service/UrlShortener.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/module/Core/src/Action/QrCodeAction.php b/module/Core/src/Action/QrCodeAction.php index ef294265..d03e4c4d 100644 --- a/module/Core/src/Action/QrCodeAction.php +++ b/module/Core/src/Action/QrCodeAction.php @@ -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); diff --git a/module/Core/src/Service/UrlShortener.php b/module/Core/src/Service/UrlShortener.php index f282ba54..d286069e 100644 --- a/module/Core/src/Service/UrlShortener.php +++ b/module/Core/src/Service/UrlShortener.php @@ -152,6 +152,7 @@ class UrlShortener implements UrlShortenerInterface if ($shortUrl === null) { throw EntityDoesNotExistException::createFromEntityAndConditions(ShortUrl::class, [ 'shortCode' => $shortCode, + 'domain' => $domain, ]); }