overleaf/services/web/app/src/Features/Helpers/AsyncFormHelper.js

16 lines
330 B
JavaScript
Raw Normal View History

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)
}
}