From 51ae5059a68666753f528826821fa4ecdf63b2e9 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 29 Aug 2023 21:34:18 +0200 Subject: [PATCH] Use named group (#5213) --- src/github/prComment.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 57ecf9d8c1..e041e46364 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -186,7 +186,7 @@ export class TemporaryComment extends CommentBase { } } -const SUGGESTION_EXPRESSION = /```suggestion(\r\n|\n)(([\s\S]*?)(\r\n|\n))?```/; +const SUGGESTION_EXPRESSION = /```suggestion(\r\n|\n)((?[\s\S]*?)(\r\n|\n))?```/; export class GHPRComment extends CommentBase { public commentId: string; @@ -286,9 +286,10 @@ export class GHPRComment extends CommentBase { } get suggestion(): string | undefined { - const suggestionBody = this.rawComment.body.match(SUGGESTION_EXPRESSION); - if (suggestionBody?.length === 5) { - return suggestionBody[3] ? `${suggestionBody[3]}\n` : ''; + const match = this.rawComment.body.match(SUGGESTION_EXPRESSION); + const suggestionBody = match?.groups?.suggestion; + if (match?.length === 5) { + return suggestionBody ? `${suggestionBody}\n` : ''; } }