<commit_before>var fs = require('fs');

function getGroup(lines, groupName) {
  var match = /\[(.*)\]/,
      lineMatch,
      group;

  lines.forEach(function(line, i) {
    lineMatch = line.match(match);

    if (lineMatch && lineMatch[1] === groupName) {
      group = lines.slice(i + 1, i + 5);
    }
  });

  return group;
}

function validatedConfig(config) {
  if (config.host.indexOf('https://') > -1) {
    return config;
  }

  config.host = 'https://' + config.host;

  return config;
}

function buildObj(configs) {
  var result = {},
      keyVal;

  configs.forEach(function(config) {
    keyVal = config.split('=');

    result[keyVal[0].trim()] = keyVal[1].trim();
  });

  return validatedConfig(result);
}

module.exports = function(path, conf) {
  var edgerc = fs.readFileSync(path).toString().split("\n"),
      confGroup = conf || 'default',
      confData = getGroup(edgerc, confGroup);

  if (!confData) {
    throw new Error('An error occurred parsing the .edgerc file. You probably specified an invalid group name.');
  }

  return buildObj(confData);
};<commit_msg>Updated logic in buildObj method to only break the config string down on the first instance of the equal sign character to ensure that any instance of that character in the string values will be maintained.<commit_after>var fs = require('fs');

function getGroup(lines, groupName) {
    var match = /\[(.*)\]/,
        lineMatch,
        group;

    lines.forEach(function(line, i) {
        lineMatch = line.match(match);

        if (lineMatch && lineMatch[1] === groupName) {
            group = lines.slice(i + 1, i + 5);
        }
    });

    return group;
}

function validatedConfig(config) {
    if (config.host.indexOf('https://') > -1) {
        return config;
    }

    config.host = 'https://' + config.host;

    return config;
}

function buildObj(configs) {
    var result = {},
        keyVal;

    configs.forEach(function(config) {
        // Break string apart at first occurance of equal sign 
        // character in case the character is found in the value
        // strings.
        var index = config.indexOf('='),
            key = config.substr(0, index)
        val = config.substr(index + 1, config.length - index - 1);

        result[key.trim()] = val.trim();
    });

    return validatedConfig(result);
}

module.exports = function(path, conf) {
    var edgerc = fs.readFileSync(path).toString().split("\n"),
        confGroup = conf || 'default',
        confData = getGroup(edgerc, confGroup);

    if (!confData) {
        throw new Error('An error occurred parsing the .edgerc file. You probably specified an invalid group name.');
    }

    return buildObj(confData);
};
{'fraction_non_alphanumeric': 0.14322723908216137, 'fraction_numerical': 0.0048112509252405625, 'mean_word_length': 2.733425414364641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6762490', 'n_tokens_mistral': 843, 'n_tokens_neox': 809, 'n_words': 227}