Skip to content

Commit

Permalink
use JSON5 to parse the configuration object
Browse files Browse the repository at this point in the history
  • Loading branch information
nvhoanganh committed Jul 28, 2020
1 parent e264620 commit 40d0e61
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/Util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var Chance = require('chance');
var RegexEscape = require("regex-escape");
var _ = require('lodash');
var JSON5 = require('json5');

var chance = new Chance();

Expand Down Expand Up @@ -38,20 +39,12 @@ Util.prototype = {
},

getConfigurationObject: function(token) {
var configurationObject = null;
var configurationString = this.getConfigurationString(token);

if (!!configurationString) {
var configurationArray = this.splitByComma(configurationString);

configurationArray = _.map(configurationArray, this.splitByColon);

configurationObject = _.fromPairs(configurationArray);

this.setBooleans(configurationObject);
let configurationObject = null;
try {
configurationObject = JSON5.parse(this.getArray(token)[1]);
} finally {
return configurationObject;
}

return configurationObject;
},

getConfigurationString: function(token) {
Expand Down

0 comments on commit 40d0e61

Please sign in to comment.