ing-bank / lion

Fundamental white label web component features for your design system.

Home Page:https://lion-web.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@lion/ajax has a problem with overwriting pre-existing headers in fetchJson

paulcodiny opened this issue · comments

Expected behavior

It is possible to override Content-Type or Accept headers no matter how I write the headers because they are case-insensitive.

Actual Behavior

Because the "content-type" and "accept" are written in lowercase and are the keys of an object, it is possible to provide the same headers with a different case. This leads to a behavior when the Content-Type header has a value comma in the value, and that breaks some serves because it is against the specification.

How to reproduce

  1. Create an instance of ajax
  2. Call on it fetchJson('/any-url', { headers: { 'Content-Type': 'json' } });
  3. Check the "Content-Type" header in the resulting request. It will have comma in the value

Additional context

@lion/ajax v1.3.0