[ACS-5400] Fix incomplete string escaping (#8721)

* [ACS-5400] string escaping fix

* [ACS-5400] Unexpected token in json fix
This commit is contained in:
Mykyta Maliarchuk 2023-07-29 20:34:42 +02:00 committed by GitHub
parent 48898df0fa
commit 312562889c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,12 +109,12 @@ function getCommits(options: DiffOptions): Array<Commit> {
let log = shell.exec(command, { cwd: options.dir, silent: true }).toString();
// https://stackoverflow.com/a/13928240/14644447
log = log.trim().replace(/"/gm, '\\"').replace(/\^@\^/gm, '"');
log = JSON.stringify(log.trim()).slice(1, -1).replace(/\^@\^/gm, '"');
if (log.endsWith(',')) {
log = log.substring(0, log.length - 1);
}
return log.split('\n').map(str => JSON.parse(str) as Commit).filter(commit => commitAuthorAllowed(commit, authorFilter));
return log.split('\\n').map(str => JSON.parse(str) as Commit).filter(commit => commitAuthorAllowed(commit, authorFilter));
}
function commitAuthorAllowed(commit: Commit, authorFilter: string): boolean {