"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.files = files;
const path = require("path");
const path_1 = require("../path");
const array_1 = require("../util/array");
function isFilename(name) {
    const filenameRegex = /^([a-zA-Z0-9_-]+)\.[.a-zA-Z0-9]+$/;
    return filenameRegex.test(name);
}
function files() {
    return (req, res, next) => {
        const segments = req.path.split('/');
        const name = (0, array_1.last)(segments) || (0, array_1.last)(segments, -1);
        if (isFilename(name)) {
            res.sendFile(path.join(path_1.PATH_PUBLIC, name));
            return;
        }
        next();
    };
}
//# sourceMappingURL=middleware.js.map