kopia lustrzana https://github.com/c9/core
19 wiersze
401 B
JavaScript
19 wiersze
401 B
JavaScript
"use strict";
|
|
|
|
var HttpError = require("http-error");
|
|
|
|
function isDotFile(path){
|
|
return /^[.]/.test(path) ;
|
|
}
|
|
|
|
module.exports = function blockDotFiles(req, res, next){
|
|
if (!req.params.path) return next();
|
|
|
|
var pathParts = req.params.path.split("/");
|
|
|
|
if (pathParts.some(isDotFile))
|
|
return next(new HttpError.NotFound("File does not exist"));
|
|
|
|
next();
|
|
};
|