Skip to content

Commit d5386c8

Browse files
Remove redundant Accept input validation
1 parent 25d2049 commit d5386c8

2 files changed

Lines changed: 1 addition & 17 deletions

File tree

‎lib/protocol/http/header/accept.rb‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def self.parse(value)
8282
#
8383
# @parameter value [String] a raw header value containing one or more media types separated by commas.
8484
def << value
85-
self.concat(split_values(value))
85+
self.concat(value.scan(SEPARATOR).map(&:strip))
8686
end
8787

8888
# Converts the parsed header value into a raw header value.
@@ -109,12 +109,6 @@ def media_ranges
109109

110110
private
111111

112-
def split_values(value)
113-
raise TypeError, "Expected a String, got: #{value.class}" unless value.is_a?(String)
114-
115-
value.scan(SEPARATOR).map(&:strip)
116-
end
117-
118112
def parse_media_range(value)
119113
if match = value.match(MEDIA_RANGE)
120114
type = match[:type]

‎test/protocol/http/header/accept.rb‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,13 @@
136136
expect(subject.parse("").media_ranges).to be == []
137137
end
138138

139-
it "rejects nil" do
140-
expect{subject.parse(nil)}.to raise_exception(TypeError)
141-
end
142-
143139
it "ignores empty list members" do
144140
expect(subject.parse(", text/html,").media_ranges).to have_attributes(
145141
length: be == 1,
146142
)
147143
end
148144
end
149145

150-
with "#<<" do
151-
it "rejects nil" do
152-
expect{subject.new << nil}.to raise_exception(TypeError)
153-
end
154-
end
155-
156146
with "text/html;q=0, text/plain;q=0.123, application/json;q=1.000" do
157147
it "accepts standard quality factors" do
158148
expect(media_ranges.collect(&:quality_factor)).to be == [1.0, 0.123, 0.0]

0 commit comments

Comments
 (0)