<commit_before>const events = require('events')
const path = require('path')
const fs = require('fs')
const zlib = require('zlib')
const request = require('request')
const Stream = require('stream')
const CombinedStream = require('combined-stream')

const util = require('./util')
const MIMES = require('./mime-types')

const RDLMap = require('./readline-cachemap')

const confSymbol = Symbol('combo#conf')

/**
 *  Combo(opts)
 *      .static(root,prefix)
 *      .prefix(`Mixed String|Array`)
 *      .tag(`String`)
 *      .charset(`String`)
 *      .mini(`Boolean`)
 *      .gzip(`Boolean`)
 *      .maxAge(`Number`)
 *      .cacheControl(`Mixed String|REST `)
 *      .remoteMap(url,realhost)
 *      .hooks(uripath,dir,allow_ext,cat)
 *      .transform(`Mixed String|Array`)
 *      .sourcemap(`Mixed String|Array`)
 *      .middlewares()
 */

module.exports = class Combo extends events.EventEmitter {

    constructor(options) {
        super(options)
        // this.options = options || {}
        this[confSymbol] = options || {}
    }

    async _streamOfStatic(filepath, ctx) {

        let fileStat = await util.fileStatAsync(filepath)

        if (!fileStat) {
            ctx.status = 404
            return false
        }

        let lastModified = fileStat.mtime.toUTCString()

        //判断资源重复
        if (ctx.headers['if-modified-since'] && lastModified === ctx.headers['if-modified-since']) {
            ctx.status = 304
            return false
        }

        let conf = this[confSymbol]

        let mtime = fileStat.mtime.getTime().toString(16)
        let size = fileStat.size.toString(16)

        let ext = path.extname(filepath)<commit_msg>bugs: 1. 静态文件带请求参数`?`或`#`的文件无法加载;<commit_after>const events = require('events')
const path = require('path')
const fs = require('fs')
const url = require('url')
const zlib = require('zlib')
const request = require('request')
const Stream = require('stream')
const CombinedStream = require('combined-stream')

const util = require('./util')
const MIMES = require('./mime-types')

const RDLMap = require('./readline-cachemap')

const confSymbol = Symbol('combo#conf')

/**
 *  Combo(opts)
 *      .static(root,prefix)
 *      .prefix(`Mixed String|Array`)
 *      .tag(`String`)
 *      .charset(`String`)
 *      .mini(`Boolean`)
 *      .gzip(`Boolean`)
 *      .maxAge(`Number`)
 *      .cacheControl(`Mixed String|REST `)
 *      .remoteMap(url,realhost)
 *      .hooks(uripath,dir,allow_ext,cat)
 *      .transform(`Mixed String|Array`)
 *      .sourcemap(`Mixed String|Array`)
 *      .middlewares()
 */

module.exports = class Combo extends events.EventEmitter {

    constructor(options) {
        super(options)
        // this.options = options || {}
        this[confSymbol] = options || {}
    }

    async _streamOfStatic(filepath, ctx) {

        filepath = url.parse(filepath)

        filepath = filepath.pathname

        let fileStat = await util.fileStatAsync(filepath)

        if (!fileStat) {
            ctx.status = 404
            return false
        }

        let lastModified = fileStat.mtime.toUTCString()

        //判断资源重复
        if (ctx.headers['if-modified-since'] && lastModified === ctx.headers['if-modified-since']) {
            ctx.status = 304
            return false
        }

        let conf = this[confSymbol]

        let mtime = fileStat.mtime.getTime().toString(16)
        let size = fileStat.size.toString(16)

        let ext = path.extname(filepath)
{'fraction_non_alphanumeric': 0.1479136690647482, 'fraction_numerical': 0.0060431654676258995, 'mean_word_length': 2.590909090909091, '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': '2166110', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1072, 'n_words': 206}