update.js
545 Bytes
/**
* app版本判断
* @date: 2017/5/10
*/
'use strict';
const semver = require('semver');
module.exports = (version) => {
return (req, res, next) => {
if (req.yoho.isApp && req.query.app_version) {
let appVersion = req.query.app_version.split('.');
appVersion = `${appVersion[0]}.${appVersion[1]}.${appVersion[2]}`;
if (semver.lt(appVersion, version)) {
return res.redirect('http://m.yohobuy.com/passport/update');
}
}
return next();
};
};