added support for wildcard domains
This commit is contained in:
parent
e6da8277c4
commit
d6cad7cb65
21
wsclient.js
21
wsclient.js
|
@ -202,7 +202,26 @@ function run(copts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
port = portList[servername] || portList['*'];
|
port = portList[servername];
|
||||||
|
if (!port) {
|
||||||
|
// Check for any wildcard domains, sorted longest to shortest so the one with the
|
||||||
|
// biggest natural match will be found first.
|
||||||
|
Object.keys(portList).filter(function (pattern) {
|
||||||
|
return pattern[0] === '*' && pattern.length > 1;
|
||||||
|
}).sort(function (a, b) {
|
||||||
|
return b.length - a.length;
|
||||||
|
}).some(function (pattern) {
|
||||||
|
var subPiece = pattern.slice(1);
|
||||||
|
if (subPiece === servername.slice(-subPiece.length)) {
|
||||||
|
port = portList[pattern];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!port) {
|
||||||
|
port = portList['*'];
|
||||||
|
}
|
||||||
|
|
||||||
var createOpts = {
|
var createOpts = {
|
||||||
port: port
|
port: port
|
||||||
, host: '127.0.0.1'
|
, host: '127.0.0.1'
|
||||||
|
|
Loading…
Reference in New Issue