Skip to content

Commit d690571

Browse files
committed
Update Release Note Markdown processing to reduce PR link sizes.
1 parent e88e587 commit d690571

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/Support/GitHub/Release.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ public function getBodyForMarkdown(): string
5252
// Convert any URLs to Markdown links
5353
if ($this->convertLinks) {
5454
$body = preg_replace(
55-
'/(https?:\/\/[^\s]+)/',
55+
'/https?:\/\/[^\s]+\/pull\/(\d+)/',
56+
'[#$1]($0)',
57+
$body
58+
);
59+
60+
$body = preg_replace(
61+
'/(https?:\/\/(?![^\s]+\/pull\/\d+)[^\s]+)/',
5662
'[$1]($1)',
5763
$body
5864
);
@@ -67,7 +73,7 @@ public function getBodyForMarkdown(): string
6773
);
6874
}
6975

70-
return str_replace('#', '##', $body);
76+
return preg_replace('/^#/m', '##', $body);
7177
}
7278

7379
public function withoutUserLinks(bool $withoutUserLinks = true): static

0 commit comments

Comments
 (0)