Skip to content

Commit

Permalink
Fix nock compatibility (#1959)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
huturen and sindresorhus authored Jan 9, 2022
1 parent 236e744 commit bf39d2c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {Buffer} from 'node:buffer';
import {promisify, inspect} from 'node:util';
import {URL, URLSearchParams} from 'node:url';
import {checkServerIdentity} from 'node:tls';
import {request as httpRequest} from 'node:http';
import {request as httpsRequest} from 'node:https';
// DO NOT use destructuring for `https.request` and `http.request` as it's not compatible with `nock`.
import http from 'node:http';
import https from 'node:https';
import type {Readable} from 'node:stream';
import type {Socket} from 'node:net';
import type {SecureContextOptions, DetailedPeerCertificate} from 'node:tls';
Expand Down Expand Up @@ -2447,10 +2448,10 @@ export default class Options {
return http2wrapper.auto as RequestFunction;
}

return httpsRequest;
return https.request;
}

return httpRequest;
return http.request;
}

freeze() {
Expand Down

0 comments on commit bf39d2c

Please sign in to comment.