"use strict";

/**
 *
 * ----------------------------------------------------------------------------
 * express.js
 * ----------------------------------------------------------------------------
 *
 * This file is part of browser Project.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
var Browser = require('../'),
    path    = require('path');

module.exports = function(options) {

    var browser = Browser(options || {});

    var middleware = function(req, res, next) {

        Object.defineProperty(browser, 'current', {
            enumerable: false,
            configurable: false,
            writable: false,
            value: req.query.hasOwnProperty('root') ? path.join(browser.home, req.query.root) : path.join(browser.home, '/')
        });

        req.browser = browser;

        next();
    };

    return middleware;
};
"use strict";

/**
 *
 * ----------------------------------------------------------------------------
 * express.js
 * ----------------------------------------------------------------------------
 *
 * This file is part of browser Project.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
var browser = require('../'),
    path    = require('path');

module.exports = function(options) {

    var manager = browser(options || {});

    var middleware = function(req, res, next) {
        //Define new property where it's values is current list relative path
        Object.defineProperty(manager, 'current', {
            enumerable: false,
            configurable: false,
            writable: false,
            value: req.query.hasOwnProperty('root') ? path.join(browser.home, req.query.root) : path.join(browser.home, '/')
        });

        req.browser = manager;

        next();
    };

    return middleware;
};
Refactor missing new operator for coverage test. Fixes #2.