UNPKG

undici

Version:

An HTTP/1.1 client, written from scratch for Node.js

25 lines (20 loc) 588 B
'use strict' const RedirectHandler = require('../handler/redirect-handler') module.exports = opts => { const globalMaxRedirections = opts?.maxRedirections return dispatch => { return function redirectInterceptor (opts, handler) { const { maxRedirections = globalMaxRedirections, ...baseOpts } = opts if (!maxRedirections) { return dispatch(opts, handler) } const redirectHandler = new RedirectHandler( dispatch, maxRedirections, opts, handler ) return dispatch(baseOpts, redirectHandler) } } }