You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
radeno
changed the title
Get language is broken when is whole code lowercase
Get language is broken when locale part of language code is lowercase
Jan 7, 2019
By this commit #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
:/(([a-z]{2})-?([A-Z]{2})?)\s*;?\s*(q=([0-9.]+))?/gi
The text was updated successfully, but these errors were encountered: