@@ -238,6 +238,27 @@ describe('Requestor', () => {
238238 } ) ;
239239 } ) ;
240240
241+ it ( 'allows JSON content type with charset' , async ( ) => {
242+ await withServer ( async ( baseConfig , server ) => {
243+ server . byDefault ( respond ( 200 , { 'content-type' : 'application/json; charset=utf-8' } , '{}' ) ) ;
244+ const requestor = Requestor ( platform , baseConfig , env ) ;
245+
246+ const result = await requestor . fetchFlagSettings ( user ) ;
247+ expect ( result ) . toEqual ( { } ) ;
248+ } ) ;
249+ } ) ;
250+
251+ it ( 'allows extra JSON content type header' , async ( ) => {
252+ await withServer ( async ( baseConfig , server ) => {
253+ // this could happen if a proxy/gateway interpolated its own content-type header; https://github.com/launchdarkly/js-client-sdk/issues/205
254+ server . byDefault ( respond ( 200 , { 'content-type' : 'application/json, application/json; charset=utf-8' } , '{}' ) ) ;
255+ const requestor = Requestor ( platform , baseConfig , env ) ;
256+
257+ const result = await requestor . fetchFlagSettings ( user ) ;
258+ expect ( result ) . toEqual ( { } ) ;
259+ } ) ;
260+ } ) ;
261+
241262 it ( 'returns error for non-JSON content type' , async ( ) => {
242263 await withServer ( async ( baseConfig , server ) => {
243264 server . byDefault ( respond ( 200 , { 'content-type' : 'text/plain' } , 'sorry' ) ) ;
0 commit comments