<commit_before>(function() {
  var debug, mime, path, virtual;

  path = require('path');

  mime = require('mime');

  debug = require('debug')('virtual-ext');

  virtual = function(req, res, next) {
    var accept, ext, regex, url;
    debug('Executing virtual-ext middleware');
    accept = mime.getType(req.path);
    ext = path.extname(req.path);
    regex = new RegExp(`${ext}(\\?.+|)$`);
    url = req.url.replace(regex, '$1');
    if (accept && url !== req.url) {
      debug('Update Accept header from %s to %s', req.headers.accept, accept);
      req.headers.accept = accept;
      debug('Update URL from %s to %s', req.url, url);
      req.url = url;
    }
    debug('Exiting virtual-ext middleware');
    return next();
  };

  module.exports = virtual;

}).call(this);<commit_msg>refactor index for readability<commit_after>'use strict';

(() => {
  // include dependencies
  const path = require('path');
  const mime = require('mime');
  const debug = require('debug')('virtual-ext');

  const virtual = (req, res, next) => {
    debug('Executing virtual-ext middleware');
    const accept = mime.getType(req.path);
    const ext = path.extname(req.path);
    const regex = new RegExp(`${ext}(\\?.+|)$`);
    const url = req.url.replace(regex, '$1');

    if (accept && url !== req.url) {
      debug('Update Accept header from %s to %s', req.headers.accept, accept);
      req.headers.accept = accept;

      debug('Update URL from %s to %s', req.url, url);
      req.url = url;
    }

    debug('Exiting virtual-ext middleware');

    return next();
  }; // end virtual

  // export middleware as commonjs module
  module.exports = virtual;
})(); // end IIFE
{'fraction_non_alphanumeric': 0.18029850746268658, 'fraction_numerical': 0.0011940298507462687, 'mean_word_length': 3.1382716049382715, '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': '2024746', 'n_tokens_mistral': 541, 'n_tokens_neox': 528, 'n_words': 145}