Handle additional whitespaces and don't throw exception on invalid locale #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.