'use strict';

const config = require('../config');
const eq = require('./eq');

const masterById = /^\d+$/.test(config.master);
const masterByUsername = /^@?\w+$/.test(config.master);

if (!masterById && !masterByUsername) {
	throw new Error('Invalid value for `master` in config file: ' +
		config.master);
}

const isMaster = masterByUsername
	? user => user && user.username && eq.username(user.username, config.master)
	: user => user && user.id === Number(config.master);

module.exports = {
	isMaster,
};

@@ -330,24 +330,18 @@
 masterBy
-Username
+Id
 %0A%09? user
@@ -335,33 +335,35 @@
 rById%0A%09? user =%3E
- 
+%0A%09%09
 user && user.use
@@ -363,47 +363,22 @@
 ser.
-username && eq.username(user.username, 
+id === Number(
 conf
@@ -398,17 +398,19 @@
  user =%3E
- 
+%0A%09%09
 user && 
@@ -410,38 +410,63 @@
 ser && user.
-id === Number(
+username && eq.username(user.username, 
 config.maste

Fix masterById