Fixed unit tests

This commit is contained in:
Alejandro Celaya
2023-03-25 10:55:30 +01:00
parent b6e1c65c4c
commit 26f237069c
4 changed files with 44 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ use Shlinkio\Shlink\Common\Validation;
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
use function is_string;
use function preg_match;
use function substr;
@@ -134,7 +135,8 @@ class ShortUrlInputFilter extends InputFilter
return (new Validator\ValidatorChain())
->attach(new Validator\NotEmpty($emptyModifiers))
->attach(new Validator\Callback(
fn (?string $value) => ($allowNull && $value === null) || preg_match(LOOSE_URI_MATCHER, $value) === 1
// Non-strings is always allowed. Other validators will take care of those
static fn (mixed $value) => ! is_string($value) || preg_match(LOOSE_URI_MATCHER, $value) === 1,
));
}
}