diff --git a/spec/negotiator_spec.cr b/spec/negotiator_spec.cr index e03e01d..f267d92 100644 --- a/spec/negotiator_spec.cr +++ b/spec/negotiator_spec.cr @@ -86,7 +86,7 @@ struct NegotiatorTest < NegotiatorTestCase {php_pear_header, {"audio/midi"}, {"audio/midi", nil}}, {"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", {"application/rss+xml"}, {"application/rss+xml", nil}}, - # Case sensitiviy + # Case sensitivity {"text/* ; q=0.3, TEXT/html ;Q=0.7, text/html ; level=1, texT/Html ;leVel = 2 ;q=0.4, */* ; q=0.5", {"text/html; level=2"}, {"text/html", {"level" => "2"}}}, {"text/* ; q=0.3, text/html;Q=0.7, text/html ;level=1, text/html; level=2;q=0.4, */*;q=0.5", {"text/HTML; level=3"}, {"text/html", {"level" => "3"}}}, diff --git a/src/negotiator.cr b/src/negotiator.cr index 18b3042..5ebc3f8 100644 --- a/src/negotiator.cr +++ b/src/negotiator.cr @@ -12,7 +12,7 @@ class Athena::Negotiation::Negotiator < Athena::Negotiation::AbstractNegotiator( accept_sub_type = accept.sub_type priority_sub_type = priority.sub_type - intercection = accept.parameters.each_with_object({} of String => String) do |(k, v), params| + intersection = accept.parameters.each_with_object({} of String => String) do |(k, v), params| priority.parameters.tap do |pp| params[k] = v if pp.has_key?(k) && pp[k] == v end @@ -24,9 +24,9 @@ class Athena::Negotiation::Negotiator < Athena::Negotiation::AbstractNegotiator( if ( (accept_type == "*" || type_equals) && (accept_sub_type == "*" || sub_type_equals) && - intercection.size == accept.parameters.size + intersection.size == accept.parameters.size ) - score = 100 * (type_equals ? 1 : 0) + 10 * (sub_type_equals ? 1 : 0) + intercection.size + score = 100 * (type_equals ? 1 : 0) + 10 * (sub_type_equals ? 1 : 0) + intersection.size return ANG::AcceptMatch.new accept.quality * priority.quality, score, index end @@ -49,9 +49,9 @@ class Athena::Negotiation::Negotiator < Athena::Negotiation::AbstractNegotiator( if ( (accept_sub_type == "*" || priority_sub_type == "*" || sub_type_equals) && (accept_plus == "*" || priority_plus == '*' || plus_equals) && - intercection.size == accept.parameters.size + intersection.size == accept.parameters.size ) - score = 100 * (type_equals ? 1 : 0) + 10 * (sub_type_equals ? 1 : 0) + (plus_equals ? 1 : 0) + intercection.size + score = 100 * (type_equals ? 1 : 0) + 10 * (sub_type_equals ? 1 : 0) + (plus_equals ? 1 : 0) + intersection.size return ANG::AcceptMatch.new accept.quality * priority.quality, score, index end