mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
fix(std/http): properly return port 80 in _parseAddrFromStr (#6635)
This commit is contained in:
parent
be7e0f2d49
commit
e92cf5b9e8
2 changed files with 16 additions and 5 deletions
|
@ -262,7 +262,10 @@ export function _parseAddrFromStr(addr: string): HTTPOptions {
|
|||
throw new TypeError("Invalid address.");
|
||||
}
|
||||
|
||||
return { hostname: url.hostname, port: Number(url.port) };
|
||||
return {
|
||||
hostname: url.hostname,
|
||||
port: url.port === "" ? 80 : Number(url.port),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -629,20 +629,20 @@ Deno.test({
|
|||
port: 8124,
|
||||
transport: "tcp",
|
||||
};
|
||||
assertEquals(expected, server.listener.addr);
|
||||
assertEquals(server.listener.addr, expected);
|
||||
server.close();
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "server.parseAddrFromStr() should be able to parse IPV6 address",
|
||||
name: "server._parseAddrFromStr() should be able to parse IPV6 address",
|
||||
fn: (): void => {
|
||||
const addr = _parseAddrFromStr("[::1]:8124");
|
||||
const expected = {
|
||||
hostname: "[::1]",
|
||||
port: 8124,
|
||||
};
|
||||
assertEquals(expected, addr);
|
||||
assertEquals(addr, expected);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -655,7 +655,15 @@ Deno.test({
|
|||
port: 8124,
|
||||
transport: "tcp",
|
||||
};
|
||||
assertEquals(expected, server.listener.addr);
|
||||
assertEquals(server.listener.addr, expected);
|
||||
server.close();
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "server._parseAddrFromStr() port 80",
|
||||
fn: (): void => {
|
||||
const addr = _parseAddrFromStr(":80");
|
||||
assertEquals(addr.port, 80);
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue