From 8de96ca8b7bb16c15c805ae3d43524cf8c968dd2 Mon Sep 17 00:00:00 2001 From: tgpethan Date: Sun, 7 Feb 2021 00:55:27 +0000 Subject: [PATCH] Fix bug in getCountryLetters --- server/countryHelper.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/countryHelper.js b/server/countryHelper.js index 14c4b7e..b996944 100644 --- a/server/countryHelper.js +++ b/server/countryHelper.js @@ -251,12 +251,12 @@ const countryCodes = { "AI": 7 } -module.exports.countryCodes = countryCodes; +const countryCodeKeys = Object.keys(countryCodes); module.exports = { getCountryID:function(code = "") { // Get id of a country from a 2 char code - const s = code.toUpperCase(); + code = code.toUpperCase(); if (countryCodes[s] != null) return countryCodes[s]; else return 0; }, @@ -264,8 +264,11 @@ module.exports = { getCountryLetters:function(code) { // Get country char code from id for (var i = 0; i < countryCodes.length; i++) { - if (countryCodes[i] === code) return countryCodes[i]; + const countryId = countryCodes[countryCodeKeys[i]]; + if (countryId === code) return countryId; } return "XX"; } -} \ No newline at end of file +} + +module.exports.countryCodes = countryCodes; \ No newline at end of file