url-highlight icon indicating copy to clipboard operation
url-highlight copied to clipboard

Emails are incorrectly recognized as URL.

Open InfraBackend opened this issue 2 years ago • 1 comments

$urlHighlight->getUrls('[email protected]');

Will the email be used as a url, if avoided?

InfraBackend avatar Jun 16 '22 04:06 InfraBackend

Hello @DylanBack 👋 Thank you for your interest in Url highlight library.

I'm not sure if I get your issue correctly. There is a way to disable email matching. It cold be done by providing Validator instance with 4th argument (matchEmails) as false. See corresponding validator documentation section for details.

Here is a small example with disabled email matching:

<?php

require __DIR__ . '/vendor/autoload.php';

use VStelmakh\UrlHighlight\UrlHighlight;
use VStelmakh\UrlHighlight\Validator\Validator;

$validator = new Validator(true, [], [], false);
$urlHighlight = new UrlHighlight($validator);
$result = $urlHighlight->getUrls('Match example.com but not [email protected]');

var_dump($result);

// Output:
//
// array(1) {
//  [0]=>
//  string(11) "example.com"
// }

vstelmakh avatar Jun 19 '22 21:06 vstelmakh