Skip to content

Instantly share code, notes, and snippets.

@akd3vs
Forked from jfromaniello/express-static.js
Created April 7, 2014 14:52
Show Gist options
  • Save akd3vs/10021819 to your computer and use it in GitHub Desktop.
Save akd3vs/10021819 to your computer and use it in GitHub Desktop.
function onlyStatic (middleware) {
return function (req, res, next) {
var match = /(\.css|\.eot|\.gif|\.html|\.js|\.png|\.svg|\.ttf|\.woff)($|\?.*$)/ig.exec(req.originalUrl);
if (!match) return next();
middleware(req, res, next);
};
}
//usage
this.use(onlyStatic(express.static(__dirname + "/public")));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment