Skip to content

Commit 6ef0e81

Browse files
sapphi-redmonam2
authored andcommitted
chore: update
1 parent 1d5618a commit 6ef0e81

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

packages/vite/src/node/__tests__/utils.spec.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ lxMwFPTTWLFFjxbXjXmt5cEiL2mpcq13VCF2HmheCen37CyYIkrwK9IfLhBd5QQh
5959
WEIBLwjKCAscrtyayXWp6zUTmgvb8PQf//3Mh2DiEngAi3WI/nL+8Y0RkqbvxBar
6060
X2JN
6161
-----END CERTIFICATE-----
62-
`.trim() as any
62+
`.trim()
6363

6464
describe('bareImportRE', () => {
6565
test('should work with normal package name', () => {
@@ -920,9 +920,8 @@ describe('getServerUrlByHost', () => {
920920

921921
describe('extractHostnamesFromCerts', () => {
922922
test('should extract hostnames from certificate', () => {
923-
const httpsOptions = { cert: [WORKING_TEST_CERT] } as any
924-
const result = extractHostnamesFromCerts(httpsOptions.cert)
925-
923+
const certs = [WORKING_TEST_CERT]
924+
const result = extractHostnamesFromCerts(certs)
926925
expect(result).toStrictEqual([
927926
'localhost',
928927
'foo.localhost',
@@ -931,9 +930,8 @@ describe('extractHostnamesFromCerts', () => {
931930
})
932931

933932
test('should extract hostnames from multiple certificates', () => {
934-
const httpsOptions = { cert: [WORKING_TEST_CERT, WORKING_TEST_CERT] } as any
935-
const result = extractHostnamesFromCerts(httpsOptions.cert)
936-
933+
const certs = [WORKING_TEST_CERT, WORKING_TEST_CERT]
934+
const result = extractHostnamesFromCerts(certs)
937935
expect(result).toStrictEqual([
938936
'localhost',
939937
'foo.localhost',
@@ -960,7 +958,7 @@ describe('resolveServerUrls', () => {
960958
test('should handle no certificate', () => {
961959
const mockServer = createMockServer()
962960
const { options, hostname, config } = createTestConfig()
963-
const httpsOptions = {} as never
961+
const httpsOptions = {}
964962

965963
const result = resolveServerUrls(
966964
mockServer,

packages/vite/src/node/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,12 +1068,11 @@ export function resolveServerUrls(
10681068
})
10691069
}
10701070

1071-
const hostnames = extractHostnamesFromCerts(httpsOptions?.cert)
1072-
1073-
if (hostnames.length > 0) {
1071+
const hostnamesFromCert = extractHostnamesFromCerts(httpsOptions?.cert)
1072+
if (hostnamesFromCert.length > 0) {
10741073
const existings = new Set([...local, ...network])
10751074
local.push(
1076-
...hostnames
1075+
...hostnamesFromCert
10771076
.map((hostname) => `${protocol}://${hostname}:${port}${base}`)
10781077
.filter((url) => !existings.has(url)),
10791078
)

0 commit comments

Comments
 (0)