|
619 | 619 |
|
620 | 620 |
|
621 | 621 | local function _match_from_routes(routes, path, opts, ...) |
| 622 | + if opts == empty_table then |
| 623 | + local route = routes[1] |
| 624 | + if not route or route.method == 0 then |
| 625 | + return route |
| 626 | + end |
| 627 | + end |
| 628 | + |
622 | 629 | local opts_matched_exists = (opts.matched ~= nil) |
623 | 630 | for _, route in ipairs(routes) do |
624 | 631 | if route.path_op == "=" then |
@@ -657,8 +664,8 @@ local function match_route(self, path, opts, ...) |
657 | 664 | end |
658 | 665 |
|
659 | 666 | local routes = self.hash_path[path] |
660 | | - local opts_matched_exists = (opts.matched ~= nil) |
661 | 667 | if routes then |
| 668 | + local opts_matched_exists = (opts.matched ~= nil) |
662 | 669 | for _, route in ipairs(routes) do |
663 | 670 | if match_route_opts(route, opts, ...) then |
664 | 671 | if opts_matched_exists then |
@@ -693,10 +700,6 @@ local function match_route(self, path, opts, ...) |
693 | 700 | end |
694 | 701 |
|
695 | 702 | function _M.match(self, path, opts) |
696 | | - if type(path) ~= "string" then |
697 | | - error("invalid argument path", 2) |
698 | | - end |
699 | | - |
700 | 703 | local route, err = match_route(self, path, opts or empty_table) |
701 | 704 | if not route then |
702 | 705 | if err then |
|
0 commit comments