diff --git a/packages/msw/integration.js b/packages/msw/integration.js index 9182be557..b123983c1 100644 --- a/packages/msw/integration.js +++ b/packages/msw/integration.js @@ -1,14 +1,13 @@ // @ts-check const { fetch } = require('cross-fetch'); -const joinUrl = require('url-join'); -const getMockEndpoint = () => { +const getMockEndpoint = (pathName) => { if (typeof process.env.MOCK_HOST !== 'string') { throw new Error('Please define MOCK_HOST.'); } - return new URL(process.env.MOCK_HOST).toString(); + return new URL(pathName, process.env.MOCK_HOST).toString(); }; /** @type {import('hops-msw/integration').mockGraphQLQuery} */ @@ -73,7 +72,7 @@ const mockDeleteRequest = (pathName, data) => { /** @type {import('hops-msw/integration').registerServerMocks} */ const registerServerMocks = async (...mocks) => { - await fetch(joinUrl(getMockEndpoint(), '/_mocks/register'), { + await fetch(getMockEndpoint('/_mocks/register'), { method: 'POST', headers: { 'content-type': 'application/json', @@ -84,7 +83,7 @@ const registerServerMocks = async (...mocks) => { /** @type {import('hops-msw/integration').resetServerMocks} */ const resetServerMocks = async () => { - await fetch(joinUrl(getMockEndpoint(), '/_mocks/reset')); + await fetch(getMockEndpoint('/_mocks/reset')); }; module.exports = { diff --git a/packages/msw/package.json b/packages/msw/package.json index 634f6063b..950e3a089 100644 --- a/packages/msw/package.json +++ b/packages/msw/package.json @@ -25,8 +25,7 @@ "cross-fetch": "^3.1.4", "execa": "^5.1.1", "hops-mixin": "15.0.0-nightly.6", - "msw": "^0.30.0", - "url-join": "^4.0.1" + "msw": "^0.30.0" }, "homepage": "https://github.com/xing/hops/tree/master/packages/msw#readme" }