Skip to content

Commit

Permalink
Refs facebookarchive#185, remove trailing comma for .mention-bot file…
Browse files Browse the repository at this point in the history
… before JSON parse
  • Loading branch information
jeffreyleeon committed Nov 24, 2016
1 parent 0996fd8 commit b9657ac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ function configMessageGenerator(message, reviewers, pullRequester) {
}

function getRepoConfig(request) {
function removeLastAttributeComma(data) {
if (!data || typeof data !== 'string') {
console.log('RepoConfig is null or is not string type, no comma removed');
return data;
}
return data.replace(/\,(?!\s*[\{\"\w])/g, '');
}
return new Promise(function(resolve, reject) {
github.repos.getContent(request, function(err, result) {
if (err) {
reject(err);
}
try {
result.data = removeLastAttributeComma(result.data);
var data = JSON.parse(result.data);
resolve(data);
} catch (e) {
Expand Down

0 comments on commit b9657ac

Please sign in to comment.