mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04: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)
|
||
|
}
|
||
|
}
|