mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 20:11:32 +02:00
16 lines
330 B
JavaScript
16 lines
330 B
JavaScript
const _ = require('lodash')
|
|
|
|
module.exports = {
|
|
redirect
|
|
}
|
|
|
|
// redirect the request via headers or JSON response depending on the request
|
|
// format
|
|
function redirect(req, res, redir) {
|
|
if (_.get(req, ['headers', 'accept'], '').match(/^application\/json.*$/)) {
|
|
res.json({ redir })
|
|
} else {
|
|
res.redirect(redir)
|
|
}
|
|
}
|