Files
30-seconds-of-code/node_modules/gatsby/dist/commands/develop-static.js
2019-08-20 15:52:05 +02:00

37 lines
742 B
JavaScript

"use strict";
const sysPath = require(`path`);
const express = require(`express`);
const parseUrl = require(`parseurl`);
/**
* Module exports.
* @public
*/
module.exports = serveStatic;
/**
* @param {string} root
* @param {object} [options]
* @return {function}
* @public
*/
function serveStatic(root, options) {
const expressStatic = express.static(root, options);
return function (req, res, next) {
if ([`GET`, `HEAD`].includes(req.method)) {
const path = parseUrl(req).pathname;
const parsedPath = sysPath.parse(path);
if ([`.htm`, `.html`].includes(parsedPath.ext)) {
return next();
}
}
return expressStatic(req, res, next);
};
}
//# sourceMappingURL=develop-static.js.map