Skip to content

Commit

Permalink
Use named group (#5213)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored Aug 29, 2023
1 parent 07a58cb commit 51ae505
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/github/prComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)((?<suggestion>[\s\S]*?)(\r\n|\n))?```/;

export class GHPRComment extends CommentBase {
public commentId: string;
Expand Down Expand Up @@ -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` : '';
}
}

Expand Down

0 comments on commit 51ae505

Please sign in to comment.