msw 2.7.3 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -80
- package/lib/core/{GraphQLHandler-D4_CxZQj.d.mts → GraphQLHandler-BNMGdWQe.d.mts} +1 -0
- package/lib/core/{GraphQLHandler-Pox7fIFM.d.ts → GraphQLHandler-D1CSV926.d.ts} +1 -0
- package/lib/core/graphql.d.mts +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- package/lib/core/index.d.mts +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.js +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.js.map +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.mjs +1 -1
- package/lib/core/utils/url/getAbsoluteUrl.mjs.map +1 -1
- package/lib/iife/index.js +1 -1
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/src/browser/utils/getAbsoluteWorkerUrl.test.ts +1 -3
- package/src/core/handlers/GraphQLHandler.ts +1 -0
- package/src/core/utils/url/getAbsoluteUrl.test.ts +29 -11
- package/src/core/utils/url/getAbsoluteUrl.ts +1 -2
package/lib/mockServiceWorker.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.7.
|
|
11
|
+
const PACKAGE_VERSION = '2.7.4'
|
|
12
12
|
const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
package/package.json
CHANGED
|
@@ -1,29 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
* @vitest-environment jsdom
|
|
3
|
-
*/
|
|
1
|
+
// @vitest-environment jsdom
|
|
4
2
|
import { getAbsoluteUrl } from './getAbsoluteUrl'
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const rawLocation = window.location
|
|
5
|
+
|
|
6
|
+
afterAll(() => {
|
|
7
|
+
Object.defineProperty(window, 'location', {
|
|
8
|
+
value: rawLocation,
|
|
9
|
+
})
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('resolves a relative URL against the current location (default)', () => {
|
|
13
|
+
expect(getAbsoluteUrl('/reviews')).toBe('http://localhost/reviews')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('supports relative URLs starting with search parameters', () => {
|
|
17
|
+
Object.defineProperty(window, 'location', {
|
|
18
|
+
value: {
|
|
19
|
+
href: 'http://localhost/nested',
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
expect(getAbsoluteUrl('?resourceId=abc-123')).toBe(
|
|
24
|
+
'http://localhost/nested?resourceId=abc-123',
|
|
25
|
+
)
|
|
8
26
|
})
|
|
9
27
|
|
|
10
|
-
it('
|
|
11
|
-
expect(getAbsoluteUrl('/user', 'https://api.github.com')).
|
|
28
|
+
it('resolves a relative URL against a custom base URL', () => {
|
|
29
|
+
expect(getAbsoluteUrl('/user', 'https://api.github.com')).toBe(
|
|
12
30
|
'https://api.github.com/user',
|
|
13
31
|
)
|
|
14
32
|
})
|
|
15
33
|
|
|
16
34
|
it('returns a given absolute URL as-is', () => {
|
|
17
|
-
expect(getAbsoluteUrl('https://api.mswjs.io/users')).
|
|
35
|
+
expect(getAbsoluteUrl('https://api.mswjs.io/users')).toBe(
|
|
18
36
|
'https://api.mswjs.io/users',
|
|
19
37
|
)
|
|
20
38
|
})
|
|
21
39
|
|
|
22
40
|
it('returns an absolute URL given a relative path without a leading slash', () => {
|
|
23
|
-
expect(getAbsoluteUrl('users')).
|
|
41
|
+
expect(getAbsoluteUrl('users')).toBe('http://localhost/users')
|
|
24
42
|
})
|
|
25
43
|
|
|
26
44
|
it('returns a path with a pattern as-is', () => {
|
|
27
|
-
expect(getAbsoluteUrl(':api/user')).
|
|
28
|
-
expect(getAbsoluteUrl('*/resource/*')).
|
|
45
|
+
expect(getAbsoluteUrl(':api/user')).toBe('http://localhost/:api/user')
|
|
46
|
+
expect(getAbsoluteUrl('*/resource/*')).toBe('*/resource/*')
|
|
29
47
|
})
|
|
@@ -16,8 +16,7 @@ export function getAbsoluteUrl(path: string, baseUrl?: string): string {
|
|
|
16
16
|
|
|
17
17
|
// Resolve a relative request URL against a given custom "baseUrl"
|
|
18
18
|
// or the document baseURI (in the case of browser/browser-like environments).
|
|
19
|
-
const origin =
|
|
20
|
-
baseUrl || (typeof document !== 'undefined' && document.baseURI)
|
|
19
|
+
const origin = baseUrl || (typeof location !== 'undefined' && location.href)
|
|
21
20
|
|
|
22
21
|
return origin
|
|
23
22
|
? // Encode and decode the path to preserve escaped characters.
|