这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@stevenharman
Copy link
Member

Back in #317 we started using Sinatra::IndifferentHash for Sinatra v2+, but didn't handle the case of a JSON array being passed as the root element. The older #indifferent_params from Sinatra v1 did handle this case. We've roughly re-created that here, though we're a little more permissive in that we allow for things that are Hash-like (via #to_hash) and Array-like (via #to_ary) rather than relying on type.

@stevenharman stevenharman force-pushed the handle_json_array_of_params branch 5 times, most recently from 396771f to 61ae81a Compare January 15, 2020 21:28
Back in e3da8c9 we started using
Sinatra::IndifferentHash for Sinatra v2+, but didn't handle the case of
a JSON array being passed as the root element. The older
`#indifferent_params` from Sinatra v1 did handle this case. We've
roughly re-created that here, though we're a little more permissive in
that we allow for things that are Hash-like (via #to_hash) and
Array-like (via #to_ary) rather than relying on type.
@stevenharman stevenharman force-pushed the handle_json_array_of_params branch from 61ae81a to 86d6810 Compare January 15, 2020 21:43
Copy link

@ransombriggs ransombriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevenharman I would prefer to use the implementation from sinatra to avoid any unintended effects of having a more permissive implementation.

The original Sinatra v1 implementation was more restrictive, relying on
explicit type-checking to determine how to convert params. To be safe,
we'll do the same. And in effect, b/c we're always dealing with
JSON-decoded data here, we'd not expect to see something other than
Hash or Array.
@stevenharman stevenharman force-pushed the handle_json_array_of_params branch from 5c0625e to 50d50cd Compare January 15, 2020 22:33
@stevenharman stevenharman merged commit 0cc3c74 into interagent:master Jan 15, 2020
@stevenharman stevenharman deleted the handle_json_array_of_params branch January 15, 2020 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants