fannarsh/country-list

v2.2.0: new source of data has to be introduced in major version bump, since it is breaking change

Closed this issue · 2 comments

 "dependencies": {
    "country-list": "^2.1.0", // resolves to 2.2.0
  },

My packages that rely on this one was kinda broken since new data source change the mapping for getting country codes. Example, previously for "United States" the correct country code was returned, in 2.2.0 it has to be "United States of America", otherwise it will be undefined.

I do recommend to remove this version and create a new one by bumping a major number, 3.0.0
Please, see this https://semver.org/

Hi,
actually this release should have been a patch according to semver since it only fixes bugs.
And one of the bugs was that it accepted "United States" as valid input when it shouldn't have.
Using semver for a lib that is essentially a database is hard.

But I understand how this affects you and unfortunately the only solution I see is to use the overwrite() functionality.

const { overwrite, getCode } = require('country-list');
overwrite([{
  code: 'US',
  name: 'United States'
}])

console.log(getCode('United States')); // US

If you need to accept different spellings for country names I suggest looking into
https://www.npmjs.com/package/country-mapper