Skip to content

Commit

Permalink
chore(middlewares): update package.json.
Browse files Browse the repository at this point in the history
  • Loading branch information
chizuki committed Mar 1, 2023
1 parent 38eafa1 commit e20e67e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/middlewares/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"author": "chizuki",
"license": "MIT",
"dependencies": {
"@fourze/core": "workspace:*"
},
"devDependencies": {}
"@fourze/core": "workspace:*",
"maybe-types": "^0.0.3"
}
}
4 changes: 2 additions & 2 deletions packages/mock/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function createMockApp(
const autoEnable = options.autoEnable ?? true;
const activeMode = new Set<FourzeMockRequestMode>(mode);

const _host = options.host ?? globalThis.location?.host;
const _host = options.host ?? globalThis.location?.host ?? "http://localhost";

const hosts = isArray(_host) ? _host : [_host];

Expand Down Expand Up @@ -179,7 +179,7 @@ export function createMockApp(
const _service = app.service.bind(app);

const resolveUrl = (_url: string) => {
const url = new URL(_url, location.origin);
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}`;
}
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("fetch", async () => {
const app = createMockApp({
delay: "200-500",
mode: ["fetch"],
origin: "http://localhost:7609",
host: "localhost:7609",
}).use(async (req, res, next) => {
res.setHeader("x-test", "abcd");
res.appendHeader("x-test", "test");
Expand Down
1 change: 0 additions & 1 deletion test/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe("hooks", async () => {
const app = createMockApp({
delay: "200-500",
mode: ["fetch"],

})
.use("/api", async (req, res, next) => {
if (req.headers["token"]) {
Expand Down

0 comments on commit e20e67e

Please sign in to comment.