Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/rack/accept/header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def accept?(value)
qvalue(value) != 0
end

# Determines if the given header had a +value+ set, if not the header can
# be regarded as not having been present in the HTTP connection.
def present?
!values.empty?
end

# Returns a copy of the given +values+ array, sorted by quality factor
# (qvalue). Each element of the returned array is itself an array
# containing two objects: 1) the value's qvalue and 2) the original
Expand Down
7 changes: 7 additions & 0 deletions test/language_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def test_qvalue
assert_equal(0, l.qvalue('da'))
end

def test_present?
header = 'da, en-gb;q=0.8, en;q=0.7'
assert_true(L.new(header).present?)
header = ''
assert_false(L.new(header).present?)
end

def test_matches
l = L.new('da, *, en')
assert_equal(%w{*}, l.matches(''))
Expand Down