Skip to content

Commit

Permalink
fix: another try
Browse files Browse the repository at this point in the history
  • Loading branch information
gwilkes-rv committed Oct 13, 2024
1 parent 25cfa51 commit 646b3e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@ export class Bot {

try {
// Attempt to parse the JSON content
const parsedContent = JSON.parse(responseText);
let parsedContent;
if (responseText.startsWith('{')) {
parsedContent = JSON.parse(responseText);
} else {
// If it doesn't start with '{', it might be a nested JSON string
parsedContent = JSON.parse(JSON.parse(responseText));
}

// Ensure the structure is correct
if (!parsedContent.reviews) {
parsedContent = { reviews: parsedContent.reviews || [{ comment: responseText }], lgtm: false };
}

responseText = JSON.stringify(parsedContent, null, 2); // Pretty print the JSON
} catch (parseError) {
warning(`Response is not in JSON format: ${parseError}`);
Expand Down

0 comments on commit 646b3e0

Please sign in to comment.