<commit_before>export default function getCSRF() {
  const cookies = document.cookie.split('; ');
  const keys = cookies.map(cookie => cookie.split('=')[0]);
  const csrfValue = cookies[keys.indexOf('XSRF-TOKEN')].split('=')[1];
  return csrfValue;
}<commit_msg>getCSRF() should return null on failure<commit_after>export default function getCSRF() {
  try {
    const cookies = document.cookie.split('; ');
    const keys = cookies.map(cookie => cookie.split('=')[0]);
    const csrfValue = cookies[keys.indexOf('XSRF-TOKEN')].split('=')[1];
    return csrfValue;
  } catch (err) {
    return null;
  }
}
{'fraction_non_alphanumeric': 0.18016528925619835, 'fraction_numerical': 0.006611570247933884, 'mean_word_length': 4.663551401869159, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3849397', 'n_tokens_mistral': 201, 'n_tokens_neox': 205, 'n_words': 42}