Skip to content

Commit ac5f211

Browse files
authored
Merge branch 'master' into optimize_api_documentation
2 parents 04ab8f1 + 5203702 commit ac5f211

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* [#2573](https://github.com/ruby-grape/grape/pull/2573): Clean up deprecated code - [@ericproulx](https://github.com/ericproulx).
77
* [#2575](https://github.com/ruby-grape/grape/pull/2575): Refactor Api description class - [@ericproulx](https://github.com/ericproulx).
88
* [#2577](https://github.com/ruby-grape/grape/pull/2577): Deprecate `return` in endpoint execution - [@ericproulx](https://github.com/ericproulx).
9-
* [#13](https://github.com/ericproulx/grape/pull/13): Refactor endpoint helpers and error middleware integration - [@ericproulx](https://github.com/ericproulx).
9+
* [#2580](https://github.com/ruby-grape/grape/pull/2580): Refactor endpoint helpers and error middleware integration - [@ericproulx](https://github.com/ericproulx).
10+
* [#2581](https://github.com/ruby-grape/grape/pull/2581): Delegate `to_s` in Grape::API::Instance - [@ericproulx](https://github.com/ericproulx).
11+
* [#2582](https://github.com/ruby-grape/grape/pull/2582): Fix leaky slash when normalizing - [@ericproulx](https://github.com/ericproulx).
1012
* [#2583](https://github.com/ruby-grape/grape/pull/2583): Optimize api parameter documentation and memory usage - [@ericproulx](https://github.com/ericproulx).
1113
* Your contribution here.
1214

lib/grape/api/instance.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ class Instance
1919
Boolean = Grape::API::Boolean
2020

2121
class << self
22+
extend Forwardable
2223
attr_reader :instance, :base
2324
attr_accessor :configuration
2425

26+
def_delegators :base, :to_s
27+
2528
def given(conditional_option, &block)
26-
evaluate_as_instance_with_configuration(block, lazy: true) if conditional_option && block
29+
return unless conditional_option
30+
31+
mounted(&block)
2732
end
2833

2934
def mounted(&block)
@@ -35,10 +40,6 @@ def base=(grape_api)
3540
grape_api.instances << self
3641
end
3742

38-
def to_s
39-
base&.to_s || super
40-
end
41-
4243
def base_instance?
4344
self == base.base_instance
4445
end

lib/grape/router.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ class Router
1212
# normalize_path("/%ab") # => "/%AB"
1313
# https://github.com/rails/rails/blob/00cc4ff0259c0185fe08baadaa40e63ea2534f6e/actionpack/lib/action_dispatch/journey/router/utils.rb#L19
1414
def self.normalize_path(path)
15-
return +'/' unless path
15+
return '/' unless path
16+
return path if path == '/'
1617

1718
# Fast path for the overwhelming majority of paths that don't need to be normalized
18-
return path.dup if path == '/' || (path.start_with?('/') && !(path.end_with?('/') || path.match?(%r{%|//})))
19+
return path.dup if path.start_with?('/') && !(path.end_with?('/') || path.match?(%r{%|//}))
1920

2021
# Slow path
2122
encoding = path.encoding

0 commit comments

Comments
 (0)