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

18 lines
338 B
JavaScript
Raw Normal View History

const {
acceptsJson,
} = require('../../infrastructure/RequestContentTypeDetection')
module.exports = {
redirect,
}
// redirect the request via headers or JSON response depending on the request
// format
function redirect(req, res, redir) {
if (acceptsJson(req)) {
res.json({ redir })
} else {
res.redirect(redir)
}
}