Skip to content

Commit

Permalink
chore: fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
chizuki committed Feb 18, 2023
1 parent e84a8cf commit 5508751
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export interface Hostname {
}

export async function resolveHostname(
optionsHost: string | boolean | undefined
optionsHost?: string | boolean
): Promise<Hostname> {
let host: string | undefined;
if (optionsHost === undefined || optionsHost === false) {
Expand Down Expand Up @@ -192,7 +192,7 @@ export interface NormalizedAddressOptions {
protocol?: "http" | "https" | false
hostname?: string
/**
* @default "/"
* @default ""
*/
base?: string
}
Expand All @@ -207,7 +207,7 @@ export function normalizeAddress(address: AddressInfo | string | null, options:
return address;
}
const protocol = options.protocol ?? "http";
const base = options.base ?? "/";
const base = options.base ?? "";
if (isAddressInfo(address)) {
const port = address.port;
let host = options.hostname ?? address.address;
Expand Down
6 changes: 5 additions & 1 deletion test/server.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Server } from 'http';
import { defineRouter, delay, randomInt } from "@fourze/core";
import { connect, createServer, normalizeAddress, resolveServerUrls } from "@fourze/server";
import { connect, createServer, normalizeAddress, resolveHostname, resolveServerUrls } from "@fourze/server";
import express from "connect";
import axios from "axios";
import { describe, expect, it } from "vitest";
Expand Down Expand Up @@ -66,12 +66,16 @@ describe("server", async () => {
});
})


const origin = normalizeAddress(server.address(), {
protocol: "http",
hostname: host,
});



const url = `${origin ?? ""}/api/test`;
console.log(url);

const returnData = await axios
.get<typeof testData>(url)
Expand Down

0 comments on commit 5508751

Please sign in to comment.