Skip to content

Commit a2fc0f3

Browse files
committed
Prepare for 2.0.1 release.
1 parent c74bc6e commit a2fc0f3

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.0.1

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"windwalker/utilities": "^4.0",
2424
"phpunit/phpunit": "^8.0||^9.0||^10.0"
2525
},
26+
"scripts": {
27+
"test": "phpunit"
28+
},
2629
"autoload": {
2730
"psr-4": {
2831
"Asika\\Autolink\\": "src/"

src/Autolink.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function convert(string $text, array $attribs = []): string
9090
$linkNoScheme = $this->getLinkNoScheme();
9191

9292
if ($linkNoScheme) {
93-
$schemeRegex = "[(%s)\:\/\/]*";
93+
$schemeRegex = "[(%s)\:\/\/@]*";
9494
} else {
9595
$schemeRegex = "(%s)\:\/\/";
9696
}
@@ -108,7 +108,13 @@ function ($matches) use ($attribs, $linkNoScheme) {
108108
return $matches[0];
109109
}
110110

111-
if ($linkNoScheme && str_starts_with($matches[0], '://')) {
111+
if (
112+
$linkNoScheme
113+
&& (
114+
str_starts_with($matches[0], '://')
115+
|| str_starts_with($matches[0], '@')
116+
)
117+
) {
112118
return $matches[0];
113119
}
114120

src/HtmlBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Part of autolink project.
55
*
66
* @copyright Copyright (C) 2022 __ORGANIZATION__.
7-
* @license __LICENSE__
7+
* @license LGPL-2.0-or-later
88
*/
99

1010
declare(strict_types=1);

test/AutolinkTest.php

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,20 @@ public function testLinkNoScheme()
248248

249249
self::assertEquals('<a href="' . $url . '">' . $url . '</a>', $this->instance->convert($url));
250250

251-
$url = 'dømi.fo';
251+
$url = 'dømi.fo';
252252

253253
self::assertEquals('<a href="http://' . $url . '">' . $url . '</a>', $this->instance->convert($url));
254254

255-
$url = 'dømi.fo/dømi';
255+
$url = 'dømi.fo/dømi';
256256

257257
self::assertEquals('<a href="http://' . $url . '">' . $url . '</a>', $this->instance->convert($url));
258+
}
259+
260+
public function testLinkNoSchemeShouldIgnoreEmail(): void
261+
{
262+
$url = 'ABC hello@email.com CBA';
258263

264+
self::assertEquals('ABC hello@email.com CBA', $this->instance->convert($url));
259265
}
260266

261267
/**
@@ -294,7 +300,10 @@ public function testAutoEscape()
294300

295301
$url = 'https://example.com/?foo=bar&yoo=baz';
296302

297-
self::assertEquals('<a href="' . htmlspecialchars($url) . '">' . htmlspecialchars($url) . '</a>', $autolink->convert($url));
303+
self::assertEquals(
304+
'<a href="' . htmlspecialchars($url) . '">' . htmlspecialchars($url) . '</a>',
305+
$autolink->convert($url)
306+
);
298307

299308
$autolink->autoEscape(false);
300309

@@ -304,11 +313,17 @@ public function testAutoEscape()
304313

305314
$autolink->autoEscape(true);
306315

307-
self::assertEquals('<a href="mailto:' . htmlspecialchars($url) . '">' . htmlspecialchars($url) . '</a>', $autolink->convertEmail($url));
316+
self::assertEquals(
317+
'<a href="mailto:' . htmlspecialchars($url) . '">' . htmlspecialchars($url) . '</a>',
318+
$autolink->convertEmail($url)
319+
);
308320

309321
$autolink->autoEscape(false);
310322

311-
self::assertEquals('<a href="mailto:' . $url . '">' . htmlspecialchars($url) . '</a>', $autolink->convertEmail($url));
323+
self::assertEquals(
324+
'<a href="mailto:' . $url . '">' . htmlspecialchars($url) . '</a>',
325+
$autolink->convertEmail($url)
326+
);
312327
}
313328

314329
public function testConvertEmail()
@@ -361,7 +376,10 @@ public function testGetAndSetLinkBuilder()
361376
return $url . json_encode($attribs);
362377
});
363378

364-
self::assertEquals('http://google.com{"foo":"bar","href":"http:\/\/google.com"}', $this->instance->link('http://google.com', ['foo' => 'bar']));
379+
self::assertEquals(
380+
'http://google.com{"foo":"bar","href":"http:\/\/google.com"}',
381+
$this->instance->link('http://google.com', ['foo' => 'bar'])
382+
);
365383

366384
self::assertInstanceOf('Closure', $this->instance->getLinkBuilder());
367385
}
@@ -378,26 +396,26 @@ public function urlProvider()
378396
'http://www.projectup.net/blog/index.php?option=com_content&view=article&id=15726:-agile-&catid=8:pmp-pm&Itemid=18',
379397
'http://www.projectup.net/....../index.php?optio......',
380398
15,
381-
6
399+
6,
382400
],
383401
[
384402
'http://campus.asukademy.com/learning/job/84-find-internship-opportunity-through-platform.html',
385403
'http://campus.asukademy.com/....../84-find-interns......',
386404
15,
387-
6
405+
6,
388406
],
389407
[
390408
'http://user:pass@campus.asukademy.com:8888/learning/job/84-find-internship-opportunity-through-platform.html',
391409
'http://user:pass@campus.asukademy.com:8888/....../84-find-interns......',
392410
15,
393-
6
411+
6,
394412
],
395413
[
396414
'http://campus.asukademy.com/learning/job/84-find-internship-opportunity-through-platform.html',
397415
'http://campus.asukademy.com/.../84-fi...',
398416
5,
399-
3
400-
]
417+
3,
418+
],
401419
];
402420
}
403421

0 commit comments

Comments
 (0)