diff --git a/src/router/router.js b/src/router/router.js index e22b4167b..279289fc0 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -498,6 +498,17 @@ this.handlers.unshift({route: route, callback: callback}); }, + // check route is Exist. if exist, return the route + checkRoute: function (route) { + for (var i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].route.toString() === Router.prototype._routeToRegExp(route).toString()) { + return this.handlers[i]; + } + } + + return null; + }, + // remove a route match in routes unRoute: function (route) { var index = _.findIndex(this.handlers, function (handler) { diff --git a/typescript/router/router.ts b/typescript/router/router.ts index dea087262..262c9debe 100644 --- a/typescript/router/router.ts +++ b/typescript/router/router.ts @@ -26,6 +26,8 @@ export declare class History { route(route: string, callback: Function): void; + checkRoute(route: string): { route: string, callback: Function}; + unRoute(route: string): void; checkUrl(e?: Event): void;