mobile-check.js
513 Bytes
/**
* 手机访问检测
*/
'use strict';
const querystring = require('querystring');
module.exports = () => {
return (req, res, next) => {
if (req.xhr) {
return next();
}
if (req.noRefer) {
res.locals.mobileRefer = '';
} else if (req.isMobile) {
return res.redirect(req.mobileUrl || res.locals.mobileRefer ||
`//m.yohobuy.com${req.url}?${querystring.stringify(req.query)}`);
}
return next();
};
};