Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get language is broken when locale part of language code is lowercase #171

Closed
radeno opened this issue Jan 7, 2019 · 1 comment · Fixed by #172
Closed

Get language is broken when locale part of language code is lowercase #171

radeno opened this issue Jan 7, 2019 · 1 comment · Fixed by #172

Comments

@radeno
Copy link
Contributor

radeno commented 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 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.

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
@jamuhl
Copy link
Member

jamuhl commented Jan 7, 2019

Feel free to provide a PR if like to see this landed soon - else i will add it next time i work on this project.

@radeno 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants