Authored by 姜枫

fix page cache middleware bug on windows

... ... @@ -16,8 +16,8 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/'
... ... @@ -67,7 +67,7 @@ module.exports = {
port: '4444' // influxdb port
},
console: {
level: 'debug',
level: 'error',
colorize: 'all',
prettyPrint: true
}
... ...
'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);
... ...