code: function _convertUrlsToLinks(str) {
      return str.replace(URL_REG_EXP, function(match, url) {
        var punctuation = (url.match(TRAILING_CHAR_REG_EXP) || [])[1] || "",
            opening     = BRACKETS[punctuation];
        url = url.replace(TRAILING_CHAR_REG_EXP, "");
  
        if (url.split(opening).length > url.split(punctuation).length) {
          url = url + punctuation;
          punctuation = "";
        }
        var realUrl    = url,
            displayUrl = url;
        if (url.length > MAX_DISPLAY_LENGTH) {
          displayUrl = displayUrl.substr(0, MAX_DISPLAY_LENGTH) + "...";
        }
        // Add http prefix if necessary
        if (realUrl.substr(0, 4) === "www.") {
          realUrl = "http://" + realUrl;
        }
  
        return '<a href="' + realUrl + '">' + displayUrl + '</a>' + punctuation;
      });
    }
docs: This is basically a rebuild of
  the rails auto_link_urls text helper