| 10 | |
| 11 | class RedirectHandler { |
| 12 | static buildDispatch (dispatcher, maxRedirections) { |
| 13 | if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) { |
| 14 | throw new InvalidArgumentError('maxRedirections must be a positive number') |
| 15 | } |
| 16 | |
| 17 | const dispatch = dispatcher.dispatch.bind(dispatcher) |
| 18 | return (opts, originalHandler) => dispatch(opts, new RedirectHandler(dispatch, maxRedirections, opts, originalHandler)) |
| 19 | } |
| 20 | |
| 21 | constructor (dispatch, maxRedirections, opts, handler) { |
| 22 | if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) { |