<commit_before>/// <reference path="../typings/index.d.ts" />
const url = require("url");
const qs = require("querystring");
const util = require('util');
const tools = require("./help/tools");
const router = require("./router");
const formidable = require('formidable').IncomingForm;

const contentType = "Content-Type".toLowerCase();

module.exports = function (request, respone, config) {
    const _req = function () {
        this.headers = request.headers;
        request.headers.cookie = request.headers.cookie || "";
        this.cookie = qs.parse(request.headers.cookie.replace('; ', '&'));
        this.method = request.method;
        this.pathname = url.parse(request.url).pathname;
    };

    _req.prototype.afterHandleForm = function () {
        let self = this;

        if (self.method === 'GET') {
            self.form = qs.parse(request.url);
            delete self.form["/"];
            self.toResponse();
        } else if (self.method === 'POST') {
            let form = new formidable();
            form.type = self.headers[contentType];
            for (let key in config.form) {
                //noinspection JSUnfilteredForInLoop
                if (form.hasOwnProperty(key)) {
                    //noinspection JSUnfilteredForInLoop,JSUnfilteredForInLoop
                    form[key] = config.form[key];
                }
            }
            form.parse(request, function (err, fields, files) {
                self.form = fields;
                // @todo: 未传文件则置空对象
                self.form.files = tools.formatFiles(files);
                self.toResponse();
            })
        }
    };

    _req.prototype.toResponse = function () {
        router.routeHandle(this, respone);
    };

    return new _req(request);
};
<commit_msg>eslint fix<commit_after>/// <reference path='../typings/index.d.ts' />
const url = require('url');
const qs = require('querystring');
const tools = require('./help/tools');
const router = require('./router');
const formidable = require('formidable').IncomingForm;

const contentType = 'Content-Type'.toLowerCase();

module.exports = function (request, respone, config) {
    const _req = function () {
        this.headers = request.headers;
        request.headers.cookie = request.headers.cookie || '';
        this.cookie = qs.parse(request.headers.cookie.replace('; ', '&'));
        this.method = request.method;
        this.pathname = url.parse(request.url).pathname;
    };

    _req.prototype.afterHandleForm = function () {
        let self = this;

        if (self.method === 'GET') {
            self.form = qs.parse(request.url);
            delete self.form['/'];
            self.toResponse();
        } else if (self.method === 'POST') {
            let form = new formidable();
            form.type = self.headers[contentType];
            for (let key in config.form) {
                //noinspection JSUnfilteredForInLoop
                if (form.hasOwnProperty(key)) {
                    //noinspection JSUnfilteredForInLoop,JSUnfilteredForInLoop
                    form[key] = config.form[key];
                }
            }
            form.parse(request, function (err, fields, files) {
                self.form = fields;
                // @todo: 未传文件则置空对象
                self.form.files = tools.formatFiles(files);
                self.toResponse();
            });
        }
    };

    _req.prototype.toResponse = function () {
        router.routeHandle(this, respone);
    };

    return new _req(request);
};

{'fraction_non_alphanumeric': 0.1420873511060692, 'fraction_numerical': 0.0, 'mean_word_length': 1.9991496598639455, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3460693', 'n_tokens_mistral': 1010, 'n_tokens_neox': 975, 'n_words': 192}