mjackson / rack-accept

HTTP Accept* for Ruby/Rack
http://mjackson.github.com/rack-accept
47 stars 16 forks source link

Language tags should be case-insensitive #6

Closed saraogi closed 12 years ago

saraogi commented 12 years ago

Section 3.10 of RFC 2616 states that "all tags are case-insensitive". However, the comparisons here seem to depend upon case. The methods "sort", "best_of", etc make case-sensitive search.

mjackson commented 12 years ago

Would you please create a failing test case that you would expect to pass?

remi commented 12 years ago

I've created a pull request to fix this specific bug, with a test!

mttkay commented 12 years ago

I'm still running into this issue. We keep an array of supported market locale codes, which are formatted like xx_YY, and passing these to Rack::Accept::Request.best_language returns nil. I have to map(&:downcase) first for it to work?

That's tested against the latest version from master:

>> Rack::Accept::Request.new({'HTTP_ACCEPT_LANGUAGE' => 'en_GB'}).best_language(['en_GB'])
==> nil
>> Rack::Accept::Request.new({'HTTP_ACCEPT_LANGUAGE' => 'en_GB'}).best_language(['en_gb'])
=> "en_gb"

Any ideas?

mjackson commented 12 years ago

Merged this pull request earlier today. Thanks @remiprev!

mttkay commented 12 years ago

Great, thanks! Love this gem.

mjackson commented 12 years ago

Thanks!