<commit_before>"use strict";


/*global nodeca, _*/


// stdlib
var path = require('path');


// nodeca
var NLib = require('nlib');


// 3rd-party
var connect   = require('connect');
var socket_io = require('socket.io');


// HELPERS /////////////////////////////////////////////////////////////////////


function attach_connect_app(server) {
  var app = connect(), static_helpers = {}, download_root;

  app.use("/assets/", connect.compress());
  app.use("/assets/", nodeca.runtime.assets_server);

  // init downloads static middleware
  (function (options) {
    app.use("/download/", function (req, res, next) {

      options.path    = req.url;
      options.getOnly = true;

      // beautify zipball name
      res.setHeader('Content-Disposition', 'attachment; filename=fontello.zip');

      connect.static.send(req, res, next, options);
    });
  }({root: path.resolve(__dirname, '../../public/download'), maxAge: Infinity}));

  // init dummy static server
  (function (options) {
    var static_urls = ['/favicon.ico', '/robots.txt', '/snippet.png'];
<commit_msg>Add id to the content-disposition filename<commit_after>"use strict";


/*global nodeca, _*/


// stdlib
var path = require('path');


// nodeca
var NLib = require('nlib');


// 3rd-party
var connect   = require('connect');
var socket_io = require('socket.io');


// HELPERS /////////////////////////////////////////////////////////////////////


function attach_connect_app(server) {
  var app = connect(), static_helpers = {}, download_root;

  app.use("/assets/", connect.compress());
  app.use("/assets/", nodeca.runtime.assets_server);

  // init downloads static middleware
  (function (options) {
    var FINGERPRINT_RE = /-([0-9a-f]{32,40})\.[^.]+$/;
    app.use("/download/", function (req, res, next) {
      var match = FINGERPRINT_RE.exec(req.url), filename;

      options.path    = req.url;
      options.getOnly = true;

      if (match) {
        // beautify zipball name
        filename = 'filename=fontello-' + match[1].substr(0, 8) + '.zip';
        res.setHeader('Content-Disposition', 'attachment; ' + filename);
      }

      connect.static.send(req, res, next, options);
    });
  }({root: path.resolve(__dirname, '../../public/download'), maxAge: Infinity}));

  // init dummy static server
  (function (options) {
    var static_urls = ['/favicon.ico', '/robots.txt', '/snippet.png'];

{'fraction_non_alphanumeric': 0.22790113112693758, 'fraction_numerical': 0.004608294930875576, 'mean_word_length': 2.5535714285714284, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1842245', 'n_tokens_mistral': 752, 'n_tokens_neox': 715, 'n_words': 163}