Skip to content

Commit

Permalink
Fix validator to handle trailing commas (#319)
Browse files Browse the repository at this point in the history
Restrict where these apply to right after } ] or ), so that they
just apply to fix json syntax.

Signed-off-by: Galo Navarro <[email protected]>
  • Loading branch information
srvaroa authored Sep 27, 2021
1 parent 61827ef commit f20dcce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions validator/tools/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = {
sanitizeDashboard(fileContent){
return fileContent
.replace(/\"accountId\"\s*:\s*\d+\s*/g , '"accountId": 0') // Anonymize account ID
.replace(/^.+\"linkedEntityGuids\".+\n?/mg , '') // Remove linkedEntityGuids
.replace(/^.+\"permissions\".+\n?/mg , '') // Remove permissions
.replace(/\,(?!\s*?[\{\[\"\'\w])/g, ''); // Remove trailing commas
.replace(/^.+\"linkedEntityGuids\".+\n?/mg , '') // Remove linkedEntityGuids
.replace(/^.+\"permissions\".+\n?/mg , '') // Remove permissions
.replace(/[\}\)\]]\,(?!\s*?[\{\[\"\'\w])/g, '}'); // Remove trailing commas if any left after json blocks
}
}

0 comments on commit f20dcce

Please sign in to comment.