@@ -14,7 +14,7 @@ module Header
14
14
# The `accept-content-type` header represents a list of content-types that the client can accept.
15
15
class Accept < Array
16
16
# Regular expression used to split values on commas, with optional surrounding whitespace, taking into account quoted strings.
17
- SPLIT = /
17
+ SEPARATOR = /
18
18
(?: # Start non-capturing group
19
19
"[^"\\ ]*" # Match quoted strings (no escaping of quotes within)
20
20
| # OR
@@ -76,7 +76,7 @@ def split(*args)
76
76
77
77
def initialize ( value = nil )
78
78
if value
79
- super ( value . scan ( SPLIT ) . map ( &:strip ) )
79
+ super ( value . scan ( SEPARATOR ) . map ( &:strip ) )
80
80
else
81
81
end
82
82
end
@@ -87,7 +87,7 @@ def initialize(value = nil)
87
87
#
88
88
# @parameter value [String] the value or values to add, separated by commas.
89
89
def << ( value )
90
- self . concat ( value . scan ( SPLIT ) . map ( &:strip ) )
90
+ self . concat ( value . scan ( SEPARATOR ) . map ( &:strip ) )
91
91
end
92
92
93
93
# Serializes the stored values into a comma-separated string.
@@ -115,7 +115,11 @@ def parse_media_range(value)
115
115
parameters = { }
116
116
117
117
match [ :parameters ] . scan ( PARAMETER ) do |key , value , quoted_value |
118
- parameters [ key ] = quoted_value || value
118
+ if quoted_value
119
+ value = QuotedString . unquote ( quoted_value )
120
+ end
121
+
122
+ parameters [ key ] = value
119
123
end
120
124
121
125
return MediaRange . new ( type , subtype , parameters )
0 commit comments