Skip to content

Commit 9bab175

Browse files
committed
Fix email with dot
1 parent ca7c0f7 commit 9bab175

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Autolink.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ public function convertEmail(string $text, array $attribs = []): string
152152
return preg_replace_callback(
153153
$regex,
154154
function ($matches) use ($attribs) {
155+
// Email should not start with a dot.
156+
if (str_starts_with($matches[0], '.')) {
157+
return $matches[0];
158+
}
159+
155160
preg_match('/[a-zA-Z]*\=\"(.*)/', $matches[0], $inElements);
156161

157162
if (!$inElements) {

test/AutolinkTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ public function testConvertEmail()
339339
This is Email in HTML:
340340
<a href="[email protected]">LINK</a>
341341
342+
342343
<div data-target="[email protected]" wdith="100"/></div>
343344
<div data-target="mailto:[email protected]" wdith="100"/></div>
344345
@@ -356,6 +357,7 @@ public function testConvertEmail()
356357
This is Email in HTML:
357358
<a href="[email protected]">LINK</a>
358359
360+
359361
<div data-target="[email protected]" wdith="100"/></div>
360362
<div data-target="mailto:[email protected]" wdith="100"/></div>
361363

0 commit comments

Comments
 (0)