raiton 6.1.1-beta.5 → 6.3.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,10 +42,22 @@ export class RouteMatcher {
42
42
  }
43
43
 
44
44
  match(method: string, url: string): Route | null {
45
- for (const route of this._routes.values())
46
- if (route.match(method, url))
47
- return route.extractParams(url)
48
- return null
45
+ let best: Route | null = null
46
+ let bestParamCount = Number.MAX_SAFE_INTEGER
47
+
48
+ for (const route of this._routes.values()) {
49
+ if (!route.match(method, url)) continue
50
+
51
+ const paramCount = route.params.length
52
+ if (paramCount < bestParamCount) {
53
+ bestParamCount = paramCount
54
+ best = route
55
+
56
+ if (paramCount === 0) break
57
+ }
58
+ }
59
+
60
+ return best ? best.extractParams(url) : null
49
61
  }
50
62
 
51
63
  clear(): this {