Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simpler

  • Loading branch information...
commit 25a230fc4683108757deb7567e49471392476ac9 1 parent 7281ece
@joshbuddy authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 lib/data_bindings/adapters/params.rb
View
12 lib/data_bindings/adapters/params.rb
@@ -11,14 +11,10 @@ def from_params(str)
def parse_nested_query(qs, d = nil)
- params = {}
-
- (qs || '').split(d ? /[#{d}] */n : /[&;] */n).each do |p|
+ (qs || '').split(d ? /[#{d}] */n : /[&;] */n).inject({}) do |params, p|
k, v = p.split('=', 2).map { |s| CGI::unescape(s) }
normalize_params(params, k, v)
end
-
- return params
end
private
@@ -26,9 +22,9 @@ def normalize_params(params, name, v = nil)
name =~ %r(\A[\[\]]*([^\[\]]+)\]*)
k = $1 || ''
after = $' || ''
-
- return if k.empty?
-
+
+ return params if k.empty?
+
if after == ""
params[k] = v
elsif after == "[]"
Please sign in to comment.
Something went wrong with that request. Please try again.