Skip to content

Commit

Permalink
refactor: Refactor RequestOverrider (#1674)
Browse files Browse the repository at this point in the history
This makes RequestOverrider into a class and breaks its logic up into several shorter methods. The goal is to make this code easier to understand, and easier to change. There is more that can be done here, though this seems like a meaningful place to pause.
  • Loading branch information
paulmelnikow authored Aug 17, 2019
1 parent 4d0fbbf commit c09afda
Show file tree
Hide file tree
Showing 2 changed files with 333 additions and 270 deletions.
9 changes: 7 additions & 2 deletions lib/intercept.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @module nock/intercepts
*/

const RequestOverrider = require('./request_overrider')
const { InterceptedRequestHandler } = require('./request_overrider')
const common = require('./common')
const { inherits } = require('util')
const Interceptor = require('./interceptor')
Expand Down Expand Up @@ -275,7 +275,12 @@ function overrideClientRequest() {
debug('using', interceptors.length, 'interceptors')

// Use filtered interceptors to intercept requests.
const overrider = RequestOverrider(this, options, interceptors, remove)
const overrider = new InterceptedRequestHandler(
this,
options,
interceptors,
remove
)
Object.assign(this, overrider)

if (callback) {
Expand Down
Loading

0 comments on commit c09afda

Please sign in to comment.