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

Handle additional whitespaces and don't throw exception on invalid locale #211

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

jansedlon
Copy link
Contributor

Hi, following up on my #207 and someones #209.

This PR consists of two changes.

Filter out invalid locales instead of throwing exceptions

I have MANY thrown exception in Sentry from my users. Sometimes it's just bots, sometimes it's a weird combination of environment and browsers. However sometimes a request i received contains an invalid locale (see tests, there are real world Accept-Language headers). In my opinion it's better to gracefully filter out one of the invalid locales instead of throwing an exception (Intl.DateTimeFormat.supportedLocalesOf does that)

Better handling of whitespaces

Even though you have tests for random whitespaces, it doesn't handle all the cases as i have observed. The specification specifies multiple places where whitespaces can occur, i have handled the additional whitespaces and also made a test from one of my Sentry errors that bypassed your test.

@sergiodxa sergiodxa added the bug Something isn't working label Sep 17, 2024
@sergiodxa sergiodxa self-assigned this Sep 17, 2024
@sergiodxa sergiodxa merged commit 0598176 into sergiodxa:main Sep 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants