Added validateUrl optional flag for create/edit short URLs

This commit is contained in:
Alejandro Celaya
2020-09-23 19:19:17 +02:00
parent 1f78f5266a
commit d5eac3b1c3
11 changed files with 71 additions and 29 deletions

View File

@@ -71,7 +71,7 @@ class ShortUrlService implements ShortUrlServiceInterface
public function updateMetadataByShortCode(ShortUrlIdentifier $identifier, ShortUrlEdit $shortUrlEdit): ShortUrl
{
if ($shortUrlEdit->hasLongUrl()) {
$this->urlValidator->validateUrl($shortUrlEdit->longUrl());
$this->urlValidator->validateUrl($shortUrlEdit->longUrl(), $shortUrlEdit->doValidateUrl());
}
$shortUrl = $this->urlResolver->resolveShortUrl($identifier);

View File

@@ -48,7 +48,7 @@ class UrlShortener implements UrlShortenerInterface
return $existingShortUrl;
}
$this->urlValidator->validateUrl($url);
$this->urlValidator->validateUrl($url, $meta->doValidateUrl());
$this->em->beginTransaction();
$shortUrl = new ShortUrl($url, $meta, $this->domainResolver);
$shortUrl->setTags($this->tagNamesToEntities($this->em, $tags));