Merge pull request #34 from nutki/pr-2

allow case insensitive port names
This commit is contained in:
Nathan Kellenicki 2019-11-10 12:23:43 -08:00 committed by GitHub
commit be132bd9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -354,11 +354,13 @@ export class Hub extends EventEmitter {
}
protected _portLookup (port: string) {
if (!this._ports[port.toUpperCase()] && !this._virtualPorts[port.toUpperCase()]) {
throw new Error(`Port ${port.toUpperCase()} does not exist on this Hub type`);
protected _portLookup (portName: string) {
const portNameUpper = portName.toUpperCase();
const port = this._ports[portNameUpper] || this._virtualPorts[portNameUpper];
if (!port) {
throw new Error(`Port ${portNameUpper} does not exist on this Hub type`);
}
return this._ports[port] || this._virtualPorts[port];
return port;
}