Skip to content

Grape duplicates each key in the params hash with both symbol and string version fo the key #27

@ajsharp

Description

@ajsharp

Here is the offending code on line 30 in grape/endpoint.rb:

    # The parameters passed into the request as
    # well as parsed from URL segments.
    def params
      @params ||= request.params.merge(env['rack.routing_args'] || {}).inject({}) do |h,(k,v)|
        h[k.to_s] = v
        h[k.to_sym] = v
        h
      end
    end

You can get access to the unmodified version of the params through the request object, but I think most people expect the params method to return the params hash in unmodified.

This behavior causes problems for recreating a hash signature if you don't know to use request.params.

I would rather see a wrapper around the params hash as a means to provide HashWithIndifferentAccess-like functionality rather than modifying the params hash itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions