there is bug when accept language is set in whole lowercase characters. For example in Safari browser is accept language sent as
Accept-Language: en-us
in chrome:
accept-language: en-US,en;q=0.9,sk;q=0.8
Lannguage code instead en is returned as en-
So regex /(([a-z]{2})-?([A-Z]{2})?)\s*;?\s*(q=([0-9.]+))?/g fails when is language passed as en-us because it excepts uppercase characters.
By this commit https://github.com/i18next/i18next-express-middleware/pull/169
there is bug when accept language is set in whole lowercase characters. For example in Safari browser is accept language sent as
Accept-Language: en-us
in chrome:accept-language: en-US,en;q=0.9,sk;q=0.8
Lannguage code instead
en
is returned asen-
So regex
/(([a-z]{2})-?([A-Z]{2})?)\s*;?\s*(q=([0-9.]+))?/g
fails when is language passed as en-us because it excepts uppercase characters.Example here: https://regex101.com/r/2mmR4w/2
Regex should be defined with insensitive flag
i
: