From 616bdb35f344166b1fd27c629cb08d639b512028 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 18 Sep 2019 11:39:16 -0500 Subject: [PATCH] Fix using port zero --- src/cli.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index ef55d8f9..f65f055e 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -120,7 +120,7 @@ const startVscode = async (): Promise => { const server = new MainServer({ ...options, - port: typeof args.port !== "undefined" && parseInt(args.port, 10) || 8080, + port: typeof args.port !== "undefined" ? parseInt(args.port, 10) : 8080, socket: args.socket, }, args); @@ -151,7 +151,7 @@ const startVscode = async (): Promise => { if (!server.options.socket && args.open) { // The web socket doesn't seem to work if browsing with 0.0.0.0. - const openAddress = `http://localhost:${server.options.port}`; + const openAddress = serverAddress.replace(/:\/\/0.0.0.0/, "://localhost"); await open(openAddress).catch(console.error); logger.info(` - Opened ${openAddress}`); }