Skip to content

Commit

Permalink
refactor: use the WHATWG URL API instead of url.format (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin authored Dec 30, 2021
1 parent b79c72b commit 9d582d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { underline } = require('picocolors');
const Promise = require('bluebird');
const open = require('open');
const net = require('net');
const url = require('url');

module.exports = function(args) {
const app = connect();
Expand Down Expand Up @@ -76,5 +75,6 @@ function formatAddress(ip, port, root) {
hostname = 'localhost';
}

return url.format({protocol: 'http', hostname: hostname, port: port, path: root});
let path = root.startsWith("/") ? root : `/${root}`;
return new URL(`http://${hostname}:${port}${path}`).toString();
}

0 comments on commit 9d582d6

Please sign in to comment.