diff --git a/composer.json b/composer.json index d58766d..e06a579 100755 --- a/composer.json +++ b/composer.json @@ -54,6 +54,9 @@ "thecodingmachine/safe": "^3.4", "symfony/config": "^7.4.1|^8.0" }, + "conflict": { + "symfony/validator": "<7.4" + }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true diff --git a/src/Entity/Log.php b/src/Entity/Log.php index ac6d937..f7904f3 100755 --- a/src/Entity/Log.php +++ b/src/Entity/Log.php @@ -67,7 +67,7 @@ public function setSecurityUser(UserInterface $user): static #[ORM\Column] protected string $requestMethod = ''; - #[Assert\Url] + #[Assert\Url(requireTld: false)] #[ORM\Column(type: 'text', length: self::MAX_STRING_LENGTH)] protected string $requestUrl = ''; diff --git a/tests/Entity/LogTest.php b/tests/Entity/LogTest.php index 3c2958b..cb4bb59 100755 --- a/tests/Entity/LogTest.php +++ b/tests/Entity/LogTest.php @@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Component\Validator\Validation; class LogTest extends TestCase { @@ -44,4 +45,14 @@ public function testConstructorAndMethods(): void $entity->setSecurityUser($user = $this->createMock(UserInterface::class)); self::assertSame($user, $entity->getUser()); } + + public function testRequestUrlWithoutTldIsValid(): void + { + $entity = new FunctionalLog(new Address(), 'entityColumn', null, 'request trace'); + $entity->setRequestContext(new RequestContext(host: 'localhost', path: '/hello'), '127.0.0.1'); + + $validator = Validation::createValidatorBuilder()->enableAttributeMapping()->getValidator(); + + self::assertCount(0, $validator->validateProperty($entity, 'requestUrl')); + } }