<commit_before>/**
 * Module dependencies.
 */

var marked = require('marked')
  , basic = require('http-auth')({
      authRealm : "Private area."
    , authList : ['pepe:tortugasninja']
  })
  , has = Object.prototype.hasOwnProperty
  , crypto = require('crypto');

/**
 * Basic access restriction middleware
 * for authenticated users.
 */

exports.restrict = function restrict(req, res, next){
  if(req.isAuthenticated()) {
    next();
  } else {
    // we should actually redirect
    // to a login page...
    res.format({
      html: function () {
        res.redirect('/auth/facebook');
      },
      json: function() {
        res.json({
          error: "Can't vote without login in.",
          action: {
            redirect: '/auth/facebook'
          }
        })
      }
    });
  }
};

/**
 * Basic HTTP-Auth restriction middleware
 * for production access only.
 */

exports.httpAuth = function httpAuth(app) {
  return function(req, res, next) {
    basic.apply(req, res, function(username, b, c, d) {
      return next();
    });
  }
};

/**
 * View helper for markdown convertion
 * to html via Jade.
 */

exports.md = function md(source, options) {
  options = options || {};
  options.sanitize = options.sanitize || true;

  // github like mardown for tabs and newlines
  source = source
  // \r\n and \r -> \n
  .replace(/\r\n?/g, '\n')

  // 2 newline to paragraph
  .replace(/\n\n+/, "\n\n")

  // 1 newline to br
  .replace(/([^\n]\n)(?=[^\n])/g, function(m) {
    return /\n{2}/.test(m) ? m : m.replace(/\s+$/,"") + "  \n";
  })

  // tabs to four spaces
  .replace(/\t/g, '    ');
<commit_msg>[utils] - remove undefined arguments from basic http auth<commit_after>/**
 * Module dependencies.
 */

var marked = require('marked')
  , basic = require('http-auth')({
      authRealm : "Private area."
    , authList : ['pepe:tortugasninja']
  })
  , has = Object.prototype.hasOwnProperty
  , crypto = require('crypto');

/**
 * Basic access restriction middleware
 * for authenticated users.
 */

exports.restrict = function restrict(req, res, next){
  if(req.isAuthenticated()) {
    next();
  } else {
    // we should actually redirect
    // to a login page...
    res.format({
      html: function () {
        res.redirect('/auth/facebook');
      },
      json: function() {
        res.json({
          error: "Can't vote without login in.",
          action: {
            redirect: '/auth/facebook'
          }
        })
      }
    });
  }
};

/**
 * Basic HTTP-Auth restriction middleware
 * for production access only.
 */

exports.httpAuth = function httpAuth(app) {
  return function(req, res, next) {
    basic.apply(req, res, function(username) {
      return next();
    });
  }
};

/**
 * View helper for markdown convertion
 * to html via Jade.
 */

exports.md = function md(source, options) {
  options = options || {};
  options.sanitize = options.sanitize || true;

  // github like mardown for tabs and newlines
  source = source
  // \r\n and \r -> \n
  .replace(/\r\n?/g, '\n')

  // 2 newline to paragraph
  .replace(/\n\n+/, "\n\n")

  // 1 newline to br
  .replace(/([^\n]\n)(?=[^\n])/g, function(m) {
    return /\n{2}/.test(m) ? m : m.replace(/\s+$/,"") + "  \n";
  })

  // tabs to four spaces
  .replace(/\t/g, '    ');

{'fraction_non_alphanumeric': 0.17993290637389447, 'fraction_numerical': 0.0018298261665141812, 'mean_word_length': 2.263681592039801, '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': '1502879', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1087, 'n_words': 272}