From b909655d24e3afee952205bb49ff225544cd2a6b Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 17 Jan 2023 11:49:44 -0800 Subject: [PATCH] remove newlines before replacing end bracket --- .../actions/javascript/createOrUpdateStagingDeploy/index.js | 4 ++-- .github/actions/javascript/getDeployPullRequestList/index.js | 4 ++-- .github/libs/GitUtils.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index c4c351effec2..3f2b813dd8cb 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -233,8 +233,8 @@ function getMergeLogsAsJSON(fromRef, toRef) { // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, subject => sanitizeStringForJSONParse(subject)); - // Then format as JSON and convert to a proper JS object - const json = `[${sanitizedOutput}]`.replace('},]', '}]'); + // Then remove newlines, format as JSON and convert to a proper JS object + const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); return JSON.parse(json); }); diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 599e3d4787f4..1c8909bdc760 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -166,8 +166,8 @@ function getMergeLogsAsJSON(fromRef, toRef) { // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, subject => sanitizeStringForJSONParse(subject)); - // Then format as JSON and convert to a proper JS object - const json = `[${sanitizedOutput}]`.replace('},]', '}]'); + // Then remove newlines, format as JSON and convert to a proper JS object + const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); return JSON.parse(json); }); diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index b695519f0fc0..c36a82a4056d 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -39,8 +39,8 @@ function getMergeLogsAsJSON(fromRef, toRef) { // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, subject => sanitizeStringForJSONParse(subject)); - // Then format as JSON and convert to a proper JS object - const json = `[${sanitizedOutput}]`.replace('},]', '}]'); + // Then remove newlines, format as JSON and convert to a proper JS object + const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); return JSON.parse(json); });