File tree Expand file tree Collapse file tree
tests/Feature/Support/GitHub Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function getBodyForMarkdown(): string
6767 // Change any @ tags to markdown links to GitHub
6868 if ($ this ->withUserLinks ) {
6969 $ body = preg_replace (
70- '/@([a-zA-Z0-9_]+ )/ ' ,
70+ '/@([a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])? )/ ' ,
7171 '[@$1](https://github.com/$1) ' ,
7272 $ body
7373 );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Feature \Support \GitHub ;
4+
5+ use App \Support \GitHub \Release ;
6+ use Tests \TestCase ;
7+
8+ class ReleaseTest extends TestCase
9+ {
10+ public function test_it_converts_at_mentions_to_github_user_links (): void
11+ {
12+ $ release = new Release ([
13+ 'body ' => 'Thanks to @simonhamp for the contribution. ' ,
14+ ]);
15+
16+ $ this ->assertStringContainsString (
17+ '[@simonhamp](https://github.com/simonhamp) ' ,
18+ $ release ->getBodyForMarkdown (),
19+ );
20+ }
21+
22+ public function test_it_converts_at_mentions_containing_hyphens_to_github_user_links (): void
23+ {
24+ $ release = new Release ([
25+ 'body ' => 'Shout out to @some-user and @a-b-c for shipping this. ' ,
26+ ]);
27+
28+ $ output = $ release ->getBodyForMarkdown ();
29+
30+ $ this ->assertStringContainsString ('[@some-user](https://github.com/some-user) ' , $ output );
31+ $ this ->assertStringContainsString ('[@a-b-c](https://github.com/a-b-c) ' , $ output );
32+ }
33+
34+ public function test_it_does_not_match_trailing_hyphens_in_at_mentions (): void
35+ {
36+ $ release = new Release ([
37+ 'body ' => 'Mentioning @foo- bar ' ,
38+ ]);
39+
40+ $ this ->assertStringContainsString ('[@foo](https://github.com/foo)- bar ' , $ release ->getBodyForMarkdown ());
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments