Skip to content

Commit

Permalink
Merge branch 'main' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Nov 7, 2022
2 parents 8f72804 + 41798eb commit 23a9b23
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -141,6 +141,7 @@
"regenerator-runtime": "^0.13.9",
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.8.0",
"statuses": "^2.0.0",
"ts-jest": "26",
"ts-loader": "^9.2.6",
"ts-node": "^10.1.0",
Expand Down
7 changes: 6 additions & 1 deletion src/context/fetch.ts
Expand Up @@ -3,7 +3,12 @@ import { Headers } from 'headers-polyfill'
import { MockedRequest } from '../utils/request/MockedRequest'

const useFetch: (input: RequestInfo, init?: RequestInit) => Promise<Response> =
isNodeProcess() ? require('node-fetch') : window.fetch
isNodeProcess()
? (input, init) =>
import('node-fetch').then(({ default: nodeFetch }) =>
(nodeFetch as unknown as typeof window.fetch)(input, init),
)
: window.fetch

export const augmentRequestInit = (requestInit: RequestInit): RequestInit => {
const headers = new Headers(requestInit.headers)
Expand Down
4 changes: 2 additions & 2 deletions src/node/setupServer.ts
@@ -1,5 +1,5 @@
import { ClientRequestInterceptor } from '@mswjs/interceptors/lib/interceptors/ClientRequest'
import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/lib/interceptors/XMLHttpRequest'
import { ClientRequestInterceptor } from '@mswjs/interceptors/lib/interceptors/ClientRequest/index.js'
import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/lib/interceptors/XMLHttpRequest/index.js'
import { RequestHandler } from '../handlers/RequestHandler'
import { SetupServerApi } from './SetupServerApi'

Expand Down
2 changes: 1 addition & 1 deletion src/utils/matching/matchRequestUrl.ts
@@ -1,5 +1,5 @@
import { match } from 'path-to-regexp'
import { getCleanUrl } from '@mswjs/interceptors/lib/utils/getCleanUrl'
import { getCleanUrl } from '@mswjs/interceptors/lib/utils/getCleanUrl.js'
import { normalizePath } from './normalizePath'

export type Path = string | RegExp
Expand Down

0 comments on commit 23a9b23

Please sign in to comment.