diff --git a/server/config.js b/server/config.js index a703856a..5bea252f 100644 --- a/server/config.js +++ b/server/config.js @@ -12,7 +12,6 @@ const CloudFunc = require(DIR_COMMON + 'cloudfunc'); const fullstore = require('fullstore/legacy'); const currify = require('currify/legacy'); -const wraptile = require('wraptile/legacy'); const squad = require('squad'); const promisify = require('es6-promisify'); const pullout = promisify(require('pullout/legacy')); @@ -126,9 +125,9 @@ function connection(socket) { function middle(req, res, next) { const noConfigDialog = !manage('configDialog'); - if (req.url !== apiURL + '/config') + if (req.url !== `${apiURL}/config`) return next(); - + switch(req.method) { case 'GET': get(req, res, next); diff --git a/test/server/config.js b/test/server/config.js index 7da554de..feec9df3 100644 --- a/test/server/config.js +++ b/test/server/config.js @@ -5,11 +5,14 @@ const path = require('path'); const test = require('tape'); const readjson = require('readjson'); +const diff = require('sinon-called-with-diff'); +const sinon = diff(require('sinon')); const root = '../../'; const dir = root + 'server/'; const config = require(dir + 'config'); const {_cryptoPass} = config; +const {apiURL} = require(root + 'common/cloudfunc'); const pathHomeConfig = path.join(os.homedir(), '.cloudcmd.json'); const pathConfig = path.join(__dirname, '..', '..', 'json', 'config.json'); @@ -106,3 +109,19 @@ test('config: cryptoPass', (t) => { t.end(); }); +test('config: middle: no', (t) => { + const {middle} = config; + const next = sinon.stub(); + const res = null; + const url = `${apiURL}/config`; + const method = 'POST'; + const req = { + url, + method + }; + + middle(req, res, next); + t.ok(next.calledWith(), 'should call next'); + t.end(); +}); +