…but on the staging sever, the same url gives an error only when trying to make the page public which I am not sure is the expected behaviour , I would expect the error to hit me when saving the page, not when making it public:
I tested directly the regex in the url function of the V class, and it seems that the triple hyphen in the url makes it invalid (actually anything more than one hyphen in ‘flash—art’)
Wild, we’ve just run into this exact issue trying to add press coverage from some https://flash---art.com articles. Fails on local and production servers.
As @plagasul mentioned, anything from flash---art URL fails that validation. Changing the link field options from url to custom is an okay band-aid for now, but is there any other workaround for this?
Kirby uses a regex pattern to validate URLs, it’s probably not perfect:
'url' => function ($value): bool {
// In search for the perfect regular expression: https://mathiasbynens.be/demo/url-regex
// Added localhost support and removed 127.*.*.* ip restriction
$regex = '_^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:localhost)|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$_iu';
return preg_match($regex, $value ?? '') !== 0;
},