Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Support/GitHub/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getBodyForMarkdown(): string
// Change any @ tags to markdown links to GitHub
if ($this->withUserLinks) {
$body = preg_replace(
'/@([a-zA-Z0-9_]+)/',
'/@([a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)/',
'[@$1](https://github.com/$1)',
$body
);
Expand Down
42 changes: 42 additions & 0 deletions tests/Feature/Support/GitHub/ReleaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Tests\Feature\Support\GitHub;

use App\Support\GitHub\Release;
use Tests\TestCase;

class ReleaseTest extends TestCase
{
public function test_it_converts_at_mentions_to_github_user_links(): void
{
$release = new Release([
'body' => 'Thanks to @simonhamp for the contribution.',
]);

$this->assertStringContainsString(
'[@simonhamp](https://github.com/simonhamp)',
$release->getBodyForMarkdown(),
);
}

public function test_it_converts_at_mentions_containing_hyphens_to_github_user_links(): void
{
$release = new Release([
'body' => 'Shout out to @some-user and @a-b-c for shipping this.',
]);

$output = $release->getBodyForMarkdown();

$this->assertStringContainsString('[@some-user](https://github.com/some-user)', $output);
$this->assertStringContainsString('[@a-b-c](https://github.com/a-b-c)', $output);
}

public function test_it_does_not_match_trailing_hyphens_in_at_mentions(): void
{
$release = new Release([
'body' => 'Mentioning @foo- bar',
]);

$this->assertStringContainsString('[@foo](https://github.com/foo)- bar', $release->getBodyForMarkdown());
}
}
Loading