lib/grape/middleware/versioner/accept_version_header.rb in grape-1.5.3 vs lib/grape/middleware/versioner/accept_version_header.rb in grape-1.6.0

- old
+ new

@@ -20,15 +20,13 @@ # route. class AcceptVersionHeader < Base def before potential_version = (env[Grape::Http::Headers::HTTP_ACCEPT_VERSION] || '').strip - if strict? + if strict? && potential_version.empty? # If no Accept-Version header: - if potential_version.empty? - throw :error, status: 406, headers: error_headers, message: 'Accept-Version header must be set.' - end + throw :error, status: 406, headers: error_headers, message: 'Accept-Version header must be set.' end return if potential_version.empty? # If the requested version is not supported: @@ -49,10 +47,10 @@ # By default those errors contain an `X-Cascade` header set to `pass`, which allows nesting and stacking # of routes (see Grape::Router) for more information). To prevent # this behavior, and not add the `X-Cascade` header, one can set the `:cascade` option to `false`. def cascade? - if options[:version_options] && options[:version_options].key?(:cascade) + if options[:version_options]&.key?(:cascade) options[:version_options][:cascade] else true end end