add browser detection
This commit is contained in:
parent
adebf02419
commit
6e905308ea
|
@ -2,6 +2,7 @@ const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
const minify = require('express-minify');
|
const minify = require('express-minify');
|
||||||
|
const browser = require('express-browser-detect');
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
router.use(require('./template'));
|
router.use(require('./template'));
|
||||||
|
@ -17,14 +18,6 @@ router.use(minify({
|
||||||
css_match: /.css^/,
|
css_match: /.css^/,
|
||||||
js_match: /.js^/
|
js_match: /.js^/
|
||||||
}));
|
}));
|
||||||
|
router.use(browser);
|
||||||
// TODO: Maybe move all regexes into one file? Idk
|
|
||||||
const legacy_re = /(Firefox\/[0-5]\d{0,1}|Mozilla\/[0-4]|MSIE \d{1,2}\.\d{1,2}|Windows (NT|9\d)|Linux i686|(198\d|199\d|200\d|201[0-6])|Dillo|Naenara|Navscape|Netscape|QtWeb|Prism|Tencent|i(Phone|Pad|Pod)( OS [1-5]|))/g;
|
|
||||||
|
|
||||||
router.use((req, res, next) => {
|
|
||||||
req.legacymode = req.headers['user-agent'].match(legacy_re);
|
|
||||||
// res.send(req.headers['user-agent']);return;
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
|
@ -23,6 +23,7 @@
|
||||||
"easy-crc": "^1.1.0",
|
"easy-crc": "^1.1.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-async-handler": "^1.2.0",
|
"express-async-handler": "^1.2.0",
|
||||||
|
"express-browser-detect": "^1.0.0",
|
||||||
"express-minify": "^1.0.0",
|
"express-minify": "^1.0.0",
|
||||||
"express-session": "^1.17.3",
|
"express-session": "^1.17.3",
|
||||||
"glob": "^8.1.0",
|
"glob": "^8.1.0",
|
||||||
|
|
Loading…
Reference in New Issue