Ensured trying to fetch a short URL for any operation through the API results in 404 if it does not match with porovided domain

This commit is contained in:
Alejandro Celaya
2020-02-02 12:58:26 +01:00
parent 10f79ec01d
commit 297985cf01
3 changed files with 17 additions and 24 deletions

View File

@@ -26,7 +26,7 @@ class ShortUrlResolver implements ShortUrlResolverInterface
{
/** @var ShortUrlRepository $shortUrlRepo */
$shortUrlRepo = $this->em->getRepository(ShortUrl::class);
$shortUrl = $shortUrlRepo->findOneWithDomainFallback($identifier->shortCode(), $identifier->domain());
$shortUrl = $shortUrlRepo->findOne($identifier->shortCode(), $identifier->domain());
if ($shortUrl === null) {
throw ShortUrlNotFoundException::fromNotFound($identifier);
}
@@ -39,8 +39,10 @@ class ShortUrlResolver implements ShortUrlResolverInterface
*/
public function resolveEnabledShortUrl(ShortUrlIdentifier $identifier): ShortUrl
{
$shortUrl = $this->resolveShortUrl($identifier);
if (! $shortUrl->isEnabled()) {
/** @var ShortUrlRepository $shortUrlRepo */
$shortUrlRepo = $this->em->getRepository(ShortUrl::class);
$shortUrl = $shortUrlRepo->findOneWithDomainFallback($identifier->shortCode(), $identifier->domain());
if ($shortUrl === null || ! $shortUrl->isEnabled()) {
throw ShortUrlNotFoundException::fromNotFound($identifier);
}