Skip to content

Commit 286da5b

Browse files
committed
fix: Resolve failling test cases for format hostname
1 parent 7b9ea0e commit 286da5b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/JsonSchema/Constraints/Drafts/Draft06/FormatConstraint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ private function validatePhone(string $phone): bool
169169

170170
private function validateHostname(string $host): bool
171171
{
172-
$hostnameRegex = '/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/i';
172+
$hostnameRegex = '/^(?!-)(?!.*?[^A-Za-z0-9\-\.])(?:(?!-)[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?\.)*(?!-)[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?$/';
173173

174-
return preg_match($hostnameRegex, $host) !== false;
174+
return preg_match($hostnameRegex, $host) === 1;
175175
}
176176

177177
private function validateJsonPointer(string $value): bool

0 commit comments

Comments
 (0)