Skip to content

Commit

Permalink
fix(mock): default options fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
chizukicn committed Apr 13, 2023
1 parent 8d6b979 commit 9f26675
Show file tree
Hide file tree
Showing 4 changed files with 2,201 additions and 2,650 deletions.
10 changes: 6 additions & 4 deletions packages/integrations/unplugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ const createFourzePlugin = createUnplugin((options: UnpluginFourzeOptions = {})
? options.mock
? defaultEnableMockOptions
: defaultDisableMockOptions
: options.mock ?? {
...defaultEnableMockOptions,
enable: "auto"
};
: {
...defaultEnableMockOptions,
enable: "auto",
...options.mock
};

const injectScript = mockOptions.injectScript ?? true;

Expand Down Expand Up @@ -221,6 +222,7 @@ const createFourzePlugin = createUnplugin((options: UnpluginFourzeOptions = {})
if (isClientID(id)) {
return transformCode(hmrApp.moduleNames, {
...options,
base,
mode: mockOptions.mode,
host: mockOptions.host
});
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export function createMockApp(
const resolveUrl = (_url: string) => {
const url = new URL(_url, globalThis.location?.origin ?? "http://localhost");
if ((hosts.includes(url.host) || hosts.includes(url.origin)) && (!protocol || url.protocol === protocol)) {
return `${url.pathname}${url.search}${url.hash}`;
_url = `${url.pathname}${url.search}${url.hash}`;
}
return _url;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/src/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export function createProxyXMLHttpRequest(app: FourzeMockApp) {
this.dispatchEvent(new Event("load"));
this.dispatchEvent(new Event("loadend"));
} else {
logger.debug(`Not found route by ${normalizeRoute(url, method)}.`);
logger.warn(`Not found route by ${normalizeRoute(url, method)}.`);
this.originalSend(payload);
}
}
Expand Down
Loading

0 comments on commit 9f26675

Please sign in to comment.