freeCodeCamp/server/middlewares/jade-helpers.js

21 lines
590 B
JavaScript
Raw Normal View History

2016-01-15 14:08:54 +00:00
const challengesRegex = /^(bonfire|waypoint|zipline|basejump|checkpoint):\s/i;
import config from '../../webpack.config';
const __DEV__ = process.env.NODE_ENV !== 'production';
2016-01-15 14:08:54 +00:00
export default function jadeHelpers() {
return function jadeHelpersMiddleware(req, res, next) {
res.locals.removeOldTerms = function removeOldTerms(str = '') {
2016-01-15 14:08:54 +00:00
return str.replace(challengesRegex, '');
};
res.locals.getBundleLocation = function getBundleLocation() {
return __DEV__ ?
config.output.publicPath + '/bundle.js' :
'js/bundle.js';
};
2016-01-15 14:08:54 +00:00
next();
};
}