Skip to content

Commit 77212bb

Browse files
committed
Make code a bit more compact
1 parent 6c1badb commit 77212bb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/openapi_first/router.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ def find_path_item(request_path)
101101
params = path_item[:template].match(request_path)
102102
next unless params
103103

104-
[path_item, params, params.values.sum(&:length)]
104+
[path_item, params]
105105
end
106+
return matches.first if matches.length == 1
106107

107-
matches&.min_by { |_path_item, _params, length| length }
108-
&.then { |path_item, params, _length| [path_item, params] }
108+
matches&.min_by { |match| match[1].values.sum(&:length) }
109109
end
110110
end
111111
end

0 commit comments

Comments
 (0)