diff --git a/index.js b/index.js index 77e7f00..7d750e0 100644 --- a/index.js +++ b/index.js @@ -11,9 +11,16 @@ module.exports = function (app, modulefolder, opts) { for (const f of fs.readdirSync(modulefolder)) { const regex = /(.*?)-(.*?)\.js/; let [, method, url] = regex.exec(f); - url = '/' + url.replace(/^root/i, '').replace(/\./g, '/').replace(/\/+/g, '/'); + url = + '/' + + url + .replace(/^root/i, '') + .replace(/\./g, '/') + .replace(/\/+/g, '/'); - const handler = require(('./' + modulefolder + '/' + f).replace(/\/\.\//g, '/').replace(/\/+/g, '/')); + const handler = require(('./' + modulefolder + '/' + f) + .replace(/\/\.\//g, '/') + .replace(/\/+/g, '/')); const func = (req, res, next) => { handler(req, res, next, opts); }; diff --git a/test/main.js b/test/main.js index 5ab48ad..57cb8c0 100644 --- a/test/main.js +++ b/test/main.js @@ -1,4 +1,4 @@ -const {describe, it} = require('mocha'); +const { describe, it } = require('mocha'); const expect = require('chai').expect; const requestor = require('../index'); @@ -25,6 +25,12 @@ const mock = { describe('requestor', () => { it('should detect all requests on root', () => { requestor(mock, './test/onroot', {}); - expect(mock.registered).to.have.all.keys(['post-/', 'get-/', 'put-/', 'delete-/', 'all-/']); + expect(mock.registered).to.have.all.keys([ + 'post-/', + 'get-/', + 'put-/', + 'delete-/', + 'all-/' + ]); }); });