Skip to content

Commit 6042b06

Browse files
committed
refactor: code
1 parent cb505a9 commit 6042b06

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/Server.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,8 @@ class Server {
750750
}
751751
}
752752

753-
listen(port, hostname = this.options.host, fn) {
754-
if (
755-
typeof this.options.host !== 'undefined' &&
756-
hostname !== this.options.host
757-
) {
753+
listen(port, hostname, fn) {
754+
if (typeof hostname !== 'undefined' && hostname !== this.options.host) {
758755
throw new Error(
759756
'The host specified in options is different from the host passed as an argument.'
760757
);
@@ -766,6 +763,8 @@ class Server {
766763
);
767764
}
768765

766+
hostname = this.options.host;
767+
769768
if (hostname === 'local-ip') {
770769
this.options.host =
771770
internalIp.v4.sync() || internalIp.v6.sync() || '0.0.0.0';

test/server/Server.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jest.mock('sockjs/lib/transport');
1212

1313
const baseDevConfig = {
1414
port,
15+
host: 'localhost',
1516
static: false,
1617
};
1718

0 commit comments

Comments
 (0)