@tdb/web
Version:
Common condiguration for serving a web-site and testing web-based UI components.
19 lines • 629 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var url_1 = require("url");
var common_1 = require("./common");
function fileHandler(urlPath, filePath) {
filePath = common_1.fsPath.resolve(filePath);
return function (req, res, next) {
if (req.method !== 'GET') {
return next();
}
var requestUrl = url_1.parse(req.url, true);
if (requestUrl.href !== urlPath && requestUrl.pathname !== urlPath) {
return next();
}
res.sendFile(filePath);
};
}
exports.fileHandler = fileHandler;
//# sourceMappingURL=handler.file.js.map