<commit_before>'use strict';

var setHeader = require('setheader')
  , parse = require('url').parse
  , ms = require('ms');

/**
 * Configure the CORS / Access Control headers.
 *
 * @param {Object} options
 * @returns {Function}
 * @api public
 */
function access(options) {
  options = options || {};

  // The allowed origins of the request.
  options.origins = 'origins' in options
    ? options.origins
    : '*';

  // The allowed methods for the request.
  options.methods = 'methods' in options
    ? options.methods
    : ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'OPTIONS'];

  // Allow sending of authorization and cookie information.
  options.credentials = 'credentials' in options
    ? options.credentials
    : true;

  // Cache duration of the preflight/OPTIONS request.
  options.maxAge = 'maxAge' in options
    ? options.maxAge
    : '30 days';

  // The allowed request headers.
  options.headers = 'headers' in options
    ? options.headers
    : '';

  // Server headers exposed to the user agent.
  options.exposed = 'exposed' in options
    ? options.exposed
    : '';

  //
  // Be a bit flexible in the way the arguments are supplied, transform Array's
  // in to strings and human readable numbers strings in to numbers.
  //
  ['methods', 'headers', 'exposed', 'origins'].forEach(function cleanup(key) {
    if (Array.isArray(options[key])) options[key] = options[key].join(',');
  });

  //
  // We need to multiply the value with 1000 in order to get seconds as the `ms`
  // module transforms it to seconds instead and the maxAge header should have
  // been in delta seconds instead.
  //
  if ('string' === typeof options.maxAge) options.maxAge = ms(options.maxAge) / 1000;

  var methods = options.methods.toUpperCase().split(',')
    , headers = options.headers.toLowerCase().split(',')
    , origins = options.origins.toLowerCase().split(',');

  /**
   * The actual function that handles the setting of the requests and answering
   * of the OPTIONS method.
   *
   * @param {Request} req The incoming HTTP request.
   * @param {Response} res The outgoing HTTP response.<commit_msg>[minor] Fix a comment<commit_after>'use strict';

var setHeader = require('setheader')
  , parse = require('url').parse
  , ms = require('ms');

/**
 * Configure the CORS / Access Control headers.
 *
 * @param {Object} options
 * @returns {Function}
 * @api public
 */
function access(options) {
  options = options || {};

  // The allowed origins of the request.
  options.origins = 'origins' in options
    ? options.origins
    : '*';

  // The allowed methods for the request.
  options.methods = 'methods' in options
    ? options.methods
    : ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'OPTIONS'];

  // Allow sending of authorization and cookie information.
  options.credentials = 'credentials' in options
    ? options.credentials
    : true;

  // Cache duration of the preflight/OPTIONS request.
  options.maxAge = 'maxAge' in options
    ? options.maxAge
    : '30 days';

  // The allowed request headers.
  options.headers = 'headers' in options
    ? options.headers
    : '';

  // Server headers exposed to the user agent.
  options.exposed = 'exposed' in options
    ? options.exposed
    : '';

  //
  // Be a bit flexible in the way the arguments are supplied, transform Array's
  // in to strings and human readable numbers strings in to numbers.
  //
  ['methods', 'headers', 'exposed', 'origins'].forEach(function cleanup(key) {
    if (Array.isArray(options[key])) options[key] = options[key].join(',');
  });

  //
  // The maxAge header value must be expressed in seconds so we need to convert
  // the milliseconds returned by the `ms` module in seconds.
  //
  if ('string' === typeof options.maxAge) options.maxAge = ms(options.maxAge) / 1000;

  var methods = options.methods.toUpperCase().split(',')
    , headers = options.headers.toLowerCase().split(',')
    , origins = options.origins.toLowerCase().split(',');

  /**
   * The actual function that handles the setting of the requests and answering
   * of the OPTIONS method.
   *
   * @param {Request} req The incoming HTTP request.
   * @param {Response} res The outgoing HTTP response.
{'fraction_non_alphanumeric': 0.13358778625954199, 'fraction_numerical': 0.003816793893129771, 'mean_word_length': 3.180458624127617, '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': '2901504', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1184, 'n_words': 414}