Skip to content

Commit 3000d50

Browse files
committed
chore: remove the @ symbol
1 parent f2b903f commit 3000d50

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/pr/pr-generator.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ export class PullRequestGenerator {
567567
}
568568

569569
if (release.author) {
570-
body += `*Released by [@${release.author}](https://github.com/${release.author}) on ${new Date(release.date).toLocaleDateString()}*\n\n`
570+
// Strip '@' in rendered text to avoid accidental pings
571+
body += `*Released by [${release.author}](https://github.com/${release.author}) on ${new Date(release.date).toLocaleDateString()}*\n\n`
571572
}
572573
}
573574
}
@@ -963,7 +964,8 @@ export class PullRequestGenerator {
963964
// Negative lookbehind avoids letters, numbers, dot, slash, underscore before @ (emails/paths)
964965
// Negative lookahead avoids treating trailing slash or part of longer tokens
965966
protectedText = protectedText.replace(/(?<![\w./])@([A-Z0-9-]+)(?![A-Z0-9-])/gi, (_m, user: string) => {
966-
return `[@${user}](https://github.com/${user})`
967+
// Strip '@' in rendered text to prevent any possibility of pings
968+
return `[${user}](https://github.com/${user})`
967969
})
968970

969971
// Restore inline code placeholders

test/pr-mention-sanitization.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ describe('PR mention sanitization', () => {
5353
const group = makeGroup()
5454
const body: string = await gen.generateBody(group)
5555

56-
// Plain mentions converted
57-
expect(body).toContain('[@sokra](https://github.com/sokra)')
58-
expect(body).toContain('[@mischnic](https://github.com/mischnic)')
56+
// Plain mentions converted (without '@' in rendered text)
57+
expect(body).toContain('[sokra](https://github.com/sokra)')
58+
expect(body).toContain('[mischnic](https://github.com/mischnic)')
5959

60-
// No raw @mention should remain in non-code text for those users (allow inside markdown link [@user])
61-
expect(body).not.toMatch(/(?<!\[)@sokra/)
62-
expect(body).not.toMatch(/(?<!\[)@mischnic/)
60+
// No raw @mention should remain anywhere in non-code text
61+
expect(body).not.toMatch(/@sokra/)
62+
expect(body).not.toMatch(/@mischnic/)
6363

6464
// Inline code preserved
6565
expect(body).toContain('`doSomething(@nochange)`')

0 commit comments

Comments
 (0)