<commit_before>import { Picker } from 'meteor/meteorhacks:picker';
import Files from './files';
import Settings from './settings';

/**
 * @summary Route to support antiquated file_open.php from old website
 *   to continue to allow old download links to work
 */
Picker.route('/file_open.php', (params, req, res) => {
  const fileId = params.query.id;
  const file = Files.collection.findOne({ fileId });

  if (file) {
    const { bucket, region } = Settings.get('aws');

    // HTTP 301 Permanent Redirect
    res.writeHead(
      301,
      { Location: `https://s3.${region}.amazonaws.com/${bucket}/old-website-resources/${file.fileName}` },
    );
    res.end();
  } else { res.end('This file does not exist.'); }
});
<commit_msg>Force coercion of query ID in file_open route logic from string to Number since Mongo is expected an integer.<commit_after>import { Picker } from 'meteor/meteorhacks:picker';
import Files from './files';
import Settings from './settings';

/**
 * @summary Route to support antiquated file_open.php from old website
 *   to continue to allow old download links to work
 */
Picker.route('/file_open.php', (params, req, res) => {
  const fileId = Number(params.query.id);
  const file = Files.collection.findOne({ fileId });

  if (file) {
    const { bucket, region } = Settings.get('aws');

    // HTTP 301 Permanent Redirect
    res.writeHead(
      301,
      { Location: `https://s3.${region}.amazonaws.com/${bucket}/old-website-resources/${file.fileName}` },
    );
    res.end();
  } else { res.end('This file does not exist.'); }
});

{'fraction_non_alphanumeric': 0.1531130876747141, 'fraction_numerical': 0.008894536213468869, 'mean_word_length': 3.4744318181818183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1029952', 'n_tokens_mistral': 492, 'n_tokens_neox': 476, 'n_words': 142}