Skip to content

Commit

Permalink
fix: escape username
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed May 29, 2024
1 parent 7450c9a commit a6afaf1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/github/templates/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export function RepositoryLink(repository: { name: string; html_url: string }) {
}

function escapeUsername(text: string) {
// 替换 [ 为 \[
return text.replace(/\[/g, '\\[');
return text.replace(/\[/g, '\\[').replace(/\]/g, '\\]');
}

export function SenderLink(sender: { login: string; html_url: string }) {
Expand Down
4 changes: 2 additions & 2 deletions test/github/templates/__snapshots__/comment.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ You are totally right! I'll get this fixed right away.",
exports[`github templates comment can handle issue comment created 1`] = `
{
"compactText": "[opensumi\\[bot]](https://github.com/apps/opensumi) created [comment](https://github.com/opensumi/core/pull/3703):
"compactText": "[opensumi\\[bot\\]](https://github.com/apps/opensumi) created [comment](https://github.com/opensumi/core/pull/3703):
<!-- versionInfo: PR Next | 3.0.2-next-1716281731.0 -->
🎉 PR Next publish successful!
\`\`\`
3.0.2-next-1716281731.0
\`\`\`",
"text": "#### [opensumi\\[bot]](https://github.com/apps/opensumi) created [comment](https://github.com/opensumi/core/pull/3703#issuecomment-2122122281) on [pull request](https://github.com/opensumi/core/pull/3703)
"text": "#### [opensumi\\[bot\\]](https://github.com/apps/opensumi) created [comment](https://github.com/opensumi/core/pull/3703#issuecomment-2122122281) on [pull request](https://github.com/opensumi/core/pull/3703)
#### [#3703 feat: support monaco editor worker](https://github.com/opensumi/core/pull/3703)
***
Expand Down

0 comments on commit a6afaf1

Please sign in to comment.