http_accept 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/http_accept/parser.rb +5 -1
- metadata +1 -1
data/lib/http_accept/parser.rb
CHANGED
@@ -14,9 +14,13 @@ module HTTPAccept
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
+
PARAM_PATTERN = /((\w+)\s*=\s*'([\w.]+)'|(\w+)\s*=\s*"?([\w.]+)"?)/
|
18
|
+
|
17
19
|
def parse_params(segment)
|
18
20
|
format, *params = segment.split(";")
|
19
|
-
|
21
|
+
arr = params.map { |p| p.scan(PARAM_PATTERN).map { |a| a.drop(1) } }.
|
22
|
+
flatten.compact
|
23
|
+
params = Hash[*arr]
|
20
24
|
return [format, params]
|
21
25
|
end
|
22
26
|
end
|