File tree Expand file tree Collapse file tree
lib/flipper/api/v1/actions
spec/flipper/api/v1/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,10 +52,15 @@ def requested_feature_names
5252 return keys . map ( &:to_s ) if keys . is_a? ( Array )
5353
5454 raw_keys = raw_query_values ( "keys" )
55- return decoded_feature_names if raw_keys . empty? || raw_keys . none? { | key | key . include? ( ',' ) }
55+ return decoded_feature_names if raw_keys . empty?
5656
5757 raw_keys . flat_map do |keys |
58- keys . split ( ',' ) . map { |key | Rack ::Utils . unescape ( key ) }
58+ if keys . include? ( ',' )
59+ keys . split ( ',' ) . map { |key | Rack ::Utils . unescape ( key ) }
60+ else
61+ decoded_keys = Rack ::Utils . unescape ( keys )
62+ feature_exists? ( decoded_keys ) ? decoded_keys : decoded_keys . split ( ',' )
63+ end
5964 end
6065 end
6166
Original file line number Diff line number Diff line change 111111 end
112112 end
113113
114+ context 'with a single encoded key containing a comma' do
115+ before do
116+ flipper [ "audit,log" ] . enable
117+ get '/features?keys=audit%2Clog'
118+ end
119+
120+ it 'treats the escaped comma as part of the feature key' do
121+ expect ( last_response . status ) . to eq ( 200 )
122+ keys = json_response . fetch ( 'features' ) . map { |feature | feature . fetch ( 'key' ) }
123+ expect ( keys ) . to eq ( [ "audit,log" ] )
124+ end
125+ end
126+
114127 context 'with keys that are not existing features' do
115128 before do
116129 flipper [ :search ] . disable
You can’t perform that action at this time.
0 commit comments