|
|
|
|
|
'use strict';
|
|
|
|
|
|
const path = require('path');
|
|
|
const cachePage = require('../../config/cache');
|
|
|
const logger = global.yoho.logger;
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
function urlJoin(a, b) {
|
|
|
if (_.endsWith(a, '/') && _.startsWith(b, '/')) {
|
|
|
return a + b.substring(1, b.length);
|
|
|
} else if (!_.endsWith(a, '/') && !_.startsWith(b, '/')) {
|
|
|
return a + '/' + b;
|
|
|
} else {
|
|
|
return a + b;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = () => {
|
|
|
return (req, res, next) => {
|
...
|
...
|
@@ -11,7 +21,7 @@ module.exports = () => { |
|
|
function onRender() {
|
|
|
let route = req.route ? req.route.path : '';
|
|
|
let appPath = req.app.mountpath;
|
|
|
let key = path.join(appPath, route.toString()); // route may be a regexp
|
|
|
let key = urlJoin(appPath, route.toString()); // route may be a regexp
|
|
|
|
|
|
req.app.set('etag', false);
|
|
|
|
...
|
...
|
|