diff --git a/src/views/admin/components/metadata-types/url/class-tainacan-url.php b/src/views/admin/components/metadata-types/url/class-tainacan-url.php index 4b769cf06..e05e123bb 100644 --- a/src/views/admin/components/metadata-types/url/class-tainacan-url.php +++ b/src/views/admin/components/metadata-types/url/class-tainacan-url.php @@ -182,6 +182,8 @@ class URL extends Metadata_Type { // Empty strings are valid if ( !empty($url_value) ) { + $url_value = trim($url_value); + // If this seems to be a markdown link, we check if the url inside it is ok as well if ( !preg_match($reg_url, $url_value) && !preg_match($reg_full, $url_value) ) { $this->add_error( sprintf( __('"%s" is invalid. Please provide a valid, full URL or a Markdown link in the form of [label](url).', 'tainacan'), $url_value ) ); @@ -196,6 +198,8 @@ class URL extends Metadata_Type { // Empty strings are valid if ( !empty($value) ) { + $value = trim($value); + // If this seems to be a markdown link, we check if the url inside it is ok as well if ( !preg_match($reg_url, $value) && !preg_match($reg_full, $value) ) { $this->add_error( sprintf( __('"%s" is invalid. Please provide a valid, full URL or a Markdown link in the form of [label](url).', 'tainacan'), $value ) );