Skip to content

Commit

Permalink
Country names: correctly uppercase names like 'EU'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chadoh committed Aug 6, 2017
1 parent 22adc98 commit a927821
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/build-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ emojiData.forEach((datum) => {

datum.name = inflection.titleize(datum.name || '')

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

if (!datum.name) {
Expand Down

0 comments on commit a927821

Please sign in to comment.