(function (root, factory) {
    if (typeof exports === 'object') {
        factory(exports);
    } else if (typeof define === 'function' && define.amd) {
        define(['exports'], factory);
    } else {
        factory(window);
    }
})(this, function (exports) {
    exports.Router = function (prefix) {
        var routes = [],
            defaultController,
            routeClass = function (rule, controller) {
                var values;

                function match(url) {
                    var pattern = rule
                        .replace(/(\/)/g, '\\/')
                        .replace(/(:\w+)/g, '([^/]+)');
                    pattern = new RegExp('^' + pattern + '$');
                    values = pattern.exec(url);
                    return !!values;
                }

                function run() {
                    var request = {},
                        keys = rule.match(/(:\w+)/g) || [];
                    for (var i = 0; i < keys.length; i++) {
                        var key = keys[i].substr(1);
                        request[key] = values[i + 1];
                    }
                    return controller(request);
                }

                return {
                    match: match,
                    run: run
                };
            };

        /**
         * Add new route
         * @param {string} rule
         * @param {function} controller
         * @returns {Router}
         */
        function when(rule, controller) {
            routes.push(new routeClass(rule, controller));
            return this;
        }

        /**
         * Set default route
         * @param controller
         * @returns {Router}
         */
        function otherwise(controller) {
            defaultController = controller;
            return this;
        }

        /**
         * Match route by url
         * @param {string} url
         * @returns {*}
         */
        function match(url) {
            var result, found = false;
            for (var i = 0; i < routes.length; i++) {
                if (routes[i].match(url)) {
                    found = true;
                    result = routes[i].run();
                    break;
                }
            }
            if (!found) {
                result = defaultController();
            }
            return result;
        }

        /**
         * Watch hash for changes
         */
        function listen() {
            var lastUrl, currentUrl,
                check = function () {
                    currentUrl = window.location.hash.substr(('#' + prefix).length) || '/';
                    if (lastUrl !== currentUrl) {
                        lastUrl = currentUrl;
                        match(currentUrl);
                    }
                };
            check();
            if ("onhashchange" in window && (!document.documentMode || document.documentMode >= 8)) {
                window.onhashchange = check;
            } else {
                setInterval(check, 50);
            }
        }

        return {
            when: when,
            otherwise: otherwise,
            match: match,
            listen: listen
        };
    };
});
@@ -368,26 +368,21 @@
         
-r
+R
 oute
-Class
  = funct
@@ -1518,18 +1518,13 @@
 new 
-r
+R
 oute
-Class
 (rul

update class name