Skip to content

Commit 79eb585

Browse files
authored
Merge pull request #120 from 2kjiejie/index
refactor: using indexOf to check unique host
2 parents 946f3e1 + f083a22 commit 79eb585

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/portfinder.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,9 @@ exports.getPort = function (options, callback) {
142142
}
143143

144144
if (options.host) {
145-
146-
var hasUserGivenHost;
147-
for (var i = 0; i < exports._defaultHosts.length; i++) {
148-
if (exports._defaultHosts[i] === options.host) {
149-
hasUserGivenHost = true;
150-
break;
151-
}
145+
if (exports._defaultHosts.indexOf(options.host) !== -1) {
146+
exports._defaultHosts.push(options.host)
152147
}
153-
154-
if (!hasUserGivenHost) {
155-
exports._defaultHosts.push(options.host);
156-
}
157-
158148
}
159149

160150
var openPorts = [], currentHost;

0 commit comments

Comments
 (0)