DEV Community

Ola Johansson
Ola Johansson

Posted on

Trying to parse "accept-language" header, beware of extra spaces

For some reason i've decided to parse this header myself the other day, shouldn't be that hard i supposed. And it wasn't that hard and everything was working perfectly locally.

Then i deployed this to my prod and things started to act weird. Only one language was detected and so forth. Finally i noticed that in prod my header string looked like this.

"sv, fr; q=0.9, en; q=0.8, no; q=0.7"

and locally it looked like this


I'm not sure why and I'm not sure what is more correct. But i just needed to add some trim to my parsing method and now things works.

Top comments (0)