Country names: correctly uppercase names like 'EU'

Always perform the capitalization-correction for country names. If we
did this naïvely, using the same regex as before, it would change things
like "Falkland Islands" to "Falkland ISLANDS". The new regex checks on
word boundary, `\b`, instead of space, `\s`, which means even single
words like `Eu` are found. It then checks for exactly two letters, where
the first is uppercase and the second lowercase.

Here's exactly what it affects:

* All "Regional Indicator Symbol Letters AC"-type names that don't
have data in emojiLib
* There are some flags in emojiLib for which it uses two-character
abbreviations instead of full country names (see muan/emojilib#131).
These countries are: CN, EU, FR, DE, IT, JP, RU, KR, ES, TR, UK, US
This new regex corrects these from Cn, Eu, Fr, etc.
release
Chad Ostrowski 2017-08-06 14:05:01 -04:00
parent 22adc985b8
commit a927821c9b
1 changed files with 3 additions and 2 deletions

View File

@ -78,8 +78,9 @@ emojiData.forEach((datum) => {
datum.name = inflection.titleize(datum.name || '') datum.name = inflection.titleize(datum.name || '')
if (datum.category == 'Flags' && !emojiLibMatch) { if (datum.category == 'Flags') {
datum.name = datum.name.replace(/\s(\w+)$/, (letters) => letters.toUpperCase()) // uppercase two-letter country codes
datum.name = datum.name.replace(/\b[A-Z]([a-z])$/, letters => letters.toUpperCase())
} }
if (!datum.name) { if (!datum.name) {