diff --git a/packages/router/CHANGELOG.md b/packages/router/CHANGELOG.md index c24befd16e..9a021c4365 100644 --- a/packages/router/CHANGELOG.md +++ b/packages/router/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.33](https://github.com/thi-ng/umbrella/compare/@thi.ng/router@2.0.32...@thi.ng/router@2.0.33) (2020-09-22) + +**Note:** Version bump only for package @thi.ng/router + + + + + ## [2.0.32](https://github.com/thi-ng/umbrella/compare/@thi.ng/router@2.0.31...@thi.ng/router@2.0.32) (2020-09-22) **Note:** Version bump only for package @thi.ng/router diff --git a/packages/router/package.json b/packages/router/package.json index be94e18808..760abd419e 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@thi.ng/router", - "version": "2.0.32", + "version": "2.0.33", "description": "Generic router for browser & non-browser based applications", "module": "./index.js", "main": "./lib/index.js", diff --git a/packages/router/src/basic.ts b/packages/router/src/basic.ts index 895493794d..81e13b8af9 100644 --- a/packages/router/src/basic.ts +++ b/packages/router/src/basic.ts @@ -83,17 +83,7 @@ export class BasicRouter implements INotify { src = src.substr(1); } src = src.substr(this.config.prefix!.length); - const routes = this.config.routes, - curr = src.split(this.config.separator!); - let match; - for (let i = 0, n = routes.length; i < n; i++) { - const route = routes[i], - m = this.matchRoute(curr, route); - if (m) { - match = m; - break; - } - } + let match = this.matchRoutes(src); if (!match) { if (!this.handleRouteFailure()) { return; @@ -164,6 +154,17 @@ export class BasicRouter implements INotify { return this.config.routes.find((route) => route.id === id); } + protected matchRoutes(src: string) { + const routes = this.config.routes; + const curr = src.split(this.config.separator!); + for (let i = 0, n = routes.length; i < n; i++) { + const match = this.matchRoute(curr, routes[i]); + if (match) { + return match; + } + } + } + protected matchRoute(curr: string[], route: Route): RouteMatch | undefined { const match = route.match, n = match.length;