Skip to content

Commit 548a35c

Browse files
authored
Merge pull request #2146 from cdr/listen
2 parents 402f5eb + 11eaf0b commit 548a35c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/node/cli.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ export async function readConfigFile(configPath?: string): Promise<Args> {
401401

402402
function parseBindAddr(bindAddr: string): [string, number] {
403403
const u = new URL(`http://${bindAddr}`)
404-
return [u.hostname, parseInt(u.port, 10)]
404+
// With the http scheme 80 will be dropped so assume it's 80 if missing. This
405+
// means --bind-addr <addr> without a port will default to 80 as well and not
406+
// the code-server default.
407+
return [u.hostname, u.port ? parseInt(u.port, 10) : 80]
405408
}
406409

407410
interface Addr {

src/node/http.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,11 @@ export class HttpServer {
584584
const onListen = (): void => resolve(this.address())
585585
if (this.options.socket) {
586586
this.server.listen(this.options.socket, onListen)
587+
} else if (this.options.host) {
588+
// [] is the correct format when using :: but Node errors with them.
589+
this.server.listen(this.options.port, this.options.host.replace(/^\[|\]$/g, ""), onListen)
587590
} else {
588-
this.server.listen(this.options.port, this.options.host, onListen)
591+
this.server.listen(this.options.port, onListen)
589592
}
590593
})
591594
}

0 commit comments

Comments
 (0)