From a6afaf1bb30714bbb3caefe93eceb7304831d259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8E=E5=A3=B0?= Date: Wed, 29 May 2024 14:44:09 +0800 Subject: [PATCH] fix: escape username --- src/github/templates/components.ts | 3 +-- test/github/templates/__snapshots__/comment.test.ts.snap | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/github/templates/components.ts b/src/github/templates/components.ts index 09c6943..82be3c1 100644 --- a/src/github/templates/components.ts +++ b/src/github/templates/components.ts @@ -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 }) { diff --git a/test/github/templates/__snapshots__/comment.test.ts.snap b/test/github/templates/__snapshots__/comment.test.ts.snap index 4b2a103..cf09342 100644 --- a/test/github/templates/__snapshots__/comment.test.ts.snap +++ b/test/github/templates/__snapshots__/comment.test.ts.snap @@ -31,7 +31,7 @@ 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): 🎉 PR Next publish successful! @@ -39,7 +39,7 @@ exports[`github templates comment can handle issue comment created 1`] = ` \`\`\` 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) ***