Trying a first version.
Some checks failed
Try out action / pre-commit Autoupdate (push) Failing after 33s
Lint / pre-commit Autoupdate (push) Failing after 41s

This commit is contained in:
2024-05-28 22:09:02 +02:00
parent fd6e50aa13
commit c3b63b7fea
301 changed files with 38323 additions and 17 deletions

View File

@ -0,0 +1,21 @@
'use strict'
const RedirectHandler = require('../handler/RedirectHandler')
function createRedirectInterceptor ({ maxRedirections: defaultMaxRedirections }) {
return (dispatch) => {
return function Intercept (opts, handler) {
const { maxRedirections = defaultMaxRedirections } = opts
if (!maxRedirections) {
return dispatch(opts, handler)
}
const redirectHandler = new RedirectHandler(dispatch, maxRedirections, opts, handler)
opts = { ...opts, maxRedirections: 0 } // Stop sub dispatcher from also redirecting.
return dispatch(opts, redirectHandler)
}
}
}
module.exports = createRedirectInterceptor