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

module.exports = function(str) {
  var output = str.replace("-", "+").replace("_", "/");
  switch (output.length % 4) {
    case 0:
      break;
    case 2:
      output += "==";
      break;
    case 3:
      output += "=";
      break;
    default:
      throw "Illegal base64url string!";
  }

  var result = Base64.atob(output);

  try{
    return decodeURIComponent(escape(result));
  } catch (err) {
    return result;
  }
};<commit_msg>replace all instances of "-" and "_" in the base64 token instead of the first one<commit_after>var Base64 = require('Base64');

module.exports = function(str) {
  var output = str.replace(/-/g, "+").replace(/_/g, "/");
  switch (output.length % 4) {
    case 0:
      break;
    case 2:
      output += "==";
      break;
    case 3:
      output += "=";
      break;
    default:
      throw "Illegal base64url string!";
  }

  var result = Base64.atob(output);

  try{
    return decodeURIComponent(escape(result));
  } catch (err) {
    return result;
  }
};

{'fraction_non_alphanumeric': 0.16429249762583095, 'fraction_numerical': 0.024691358024691357, 'mean_word_length': 2.5369127516778525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '779332', 'n_tokens_mistral': 372, 'n_tokens_neox': 354, 'n_words': 89}