funktionswerk / hapi-i18n

Translation module for hapi based on mashpie's i18n module
MIT License
39 stars 22 forks source link

languageHeaderField is case sensitive? #28

Closed ghost closed 4 years ago

ghost commented 5 years ago

I wasted half hour on this, might save same time for someone else

I am using joi validation for headers and this plugin for translations. When headers are passed through joi validations, it converts the headers key to all lower cases... So Accept-Language becomes accept-language...

Now in this plugin's config, I set languageHeaderField to Accept-Language... Looks like this plugin matches the header key case sensitively... Changing the value to accept-language made it working...

I Google a bit and found this link: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 It says headers are case insensitive, thats why probably joi converts them to lowercase. It would be good if this plugin does the same...

kaywolter commented 4 years ago

Thanks a lot for pointing that out. I've published version 2.1.3, language header field is now converted to lower case.