<commit_before>module.exports = function nl2br (str, isXhtml) {
  //  discuss at: http://locutus.io/php/nl2br/
  // original by: <NAME> (http://kvz.io)
  // improved by: <NAME>
  // improved by: <NAME> (https://twitter.com/onnomarsman)
  // improved by: Atli Þór
  // improved by: <NAME> (http://brett-zamir.me)
  // improved by: Maximusya
  // bugfixed by: <NAME> (https://twitter.com/onnomarsman)
  // bugfixed by: <NAME> (http://kvz.io)
  //    input by: <NAME> (http://brett-zamir.me)
  //   example 1: nl2br('Kevin\nvan\nZonneveld')
  //   returns 1: 'Kevin<br />\nvan<br />\nZonneveld'
  //   example 2: nl2br("\nOne\nTwo\n\nThree\n", false)
  //   returns 2: '<br>\nOne<br>\nTwo<br>\n<br>\nThree<br>\n'
  //   example 3: nl2br("\nOne\nTwo\n\nThree\n", true)
  //   returns 3: '<br />\nOne<br />\nTwo<br />\n<br />\nThree<br />\n'

  // Adjust comment to avoid issue on locutus.io display
  var breakTag = (isXhtml || typeof isXhtml === 'undefined') ? '<br ' + '/>' : '<br>'

  return (str + '')
    .replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2')
}
<commit_msg>Unexpected result when str is null (#313)<commit_after>module.exports = function nl2br (str, isXhtml) {
  //  discuss at: http://locutus.io/php/nl2br/
  // original by: <NAME> (http://kvz.io)
  // improved by: <NAME>
  // improved by: <NAME> (https://twitter.com/onnomarsman)
  // improved by: <NAME>
  // improved by: <NAME> (http://brett-zamir.me)
  // improved by: Maximusya
  // bugfixed by: <NAME> (https://twitter.com/onnomarsman)
  // bugfixed by: <NAME> (http://kvz.io)
  // bugfixed by: <NAME> (http://scriptinside.blogspot.com.es/)
  //    input by: <NAME> (http://brett-zamir.me)
  //   example 1: nl2br('Kevin\nvan\nZonneveld')
  //   returns 1: 'Kevin<br />\nvan<br />\nZonneveld'
  //   example 2: nl2br("\nOne\nTwo\n\nThree\n", false)
  //   returns 2: '<br>\nOne<br>\nTwo<br>\n<br>\nThree<br>\n'
  //   example 3: nl2br("\nOne\nTwo\n\nThree\n", true)
  //   returns 3: '<br />\nOne<br />\nTwo<br />\n<br />\nThree<br />\n'
  //   example 4: nl2br(null)
  //   returns 4: ''

  // Some latest browsers when str is null return and unexpected null value
  if (typeof str === 'undefined' || str === null) {
    return ''
  }
  
  // Adjust comment to avoid issue on locutus.io display
  var breakTag = (isXhtml || typeof isXhtml === 'undefined') ? '<br ' + '/>' : '<br>'

  return (str + '')
    .replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2')
}

{'fraction_non_alphanumeric': 0.23030056864337936, 'fraction_numerical': 0.012997562956945572, 'mean_word_length': 2.7205438066465257, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 49, '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': '6404514', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1008, 'n_words': 215}