joshbuddy / http_router

A kick-ass HTTP router for use in Rack
MIT License
198 stars 44 forks source link

can't convert nil into Array in hashify_params #7

Closed marcboeker closed 13 years ago

marcboeker commented 13 years ago

Hi,

there seems to be a problem with the hashify_params method in the path.rb file.

TypeError at /
can't convert nil into Array
file: path.rb location: zip line: 29

I've tried to request 127.0.0.1:9292 without any path or query string.

Inside the hashify_params method, the variables params and variable_names look like this:

params = ["500"]
variable_names = [:image]

I've worked around this by doing some prechecks, but I'm not sure if this is a valid fix.

def hashify_params(params)
  if variable_names.size > 0
    variable_names.zip(params).inject({}) { |h, (k,v)| h[k] = v; h } 
  else
    {}
  end
end

Maybe you can have a look at it.

Thanks, Marc