mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-19 06:13:10 +01:00
Merge pull request #442 from n8henrie/master
Add test for valid username
This commit is contained in:
@@ -124,6 +124,15 @@ Server.prototype._loadConfig = function() {
|
||||
throw err;
|
||||
}
|
||||
|
||||
var accessoryCount = (config.accessories && config.accessories.length) || 0;
|
||||
|
||||
var username = config.bridge.username;
|
||||
var validMac = /^([0-9A-F]{2}:){5}([0-9A-F]{2})$/;
|
||||
if (!validMac.test(username)){
|
||||
throw new Error('Not a valid username: ' + username + '. Must be 6 pairs of colon-' +
|
||||
'separated hexadecimal chars (A-F 0-9), like a MAC address.');
|
||||
}
|
||||
|
||||
var accessoryCount = (config.accessories && config.accessories.length) || 0;
|
||||
var platformCount = (config.platforms && config.platforms.length) || 0;
|
||||
log.info("Loaded config.json with %s accessories and %s platforms.", accessoryCount, platformCount);
|
||||
|
||||
Reference in New Issue
Block a user