Skip to content

Commit effc403

Browse files
authored
Merge pull request #210 from ilri/enhancements-Oct-2023
Formatter to return the original value for unmatched countries
2 parents 175cb7a + fab41fd commit effc403

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

backend/src/shared/services/formater.service.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ export class FormatService {
5959
langISO.validate(value) ? langISO.getName(value) : value;
6060

6161
mapIsoToCountry(value: string) {
62+
const valueLower = value.toLowerCase();
6263
const country = CountryISO.get({
63-
alpha_2: value,
64-
alpha_3: value,
65-
numeric: value,
66-
name: value,
67-
common_name: value,
68-
official_name: value,
64+
alpha_2: valueLower,
65+
alpha_3: valueLower,
66+
numeric: valueLower,
67+
name: valueLower,
68+
common_name: valueLower,
69+
official_name: valueLower,
6970
}) as Country;
7071
// return country ? country.name : this.capitalizeFirstLetter(value);
7172
return country ? country.name : value;
@@ -91,7 +92,7 @@ export class FormatService {
9192
if (addOn == 'country')
9293
value = value
9394
.split(',')
94-
.map((d) => this.mapIsoToCountry(d.trim().toLowerCase()));
95+
.map((d) => this.mapIsoToCountry(d.trim()));
9596
if (addOn == 'language')
9697
value = value
9798
.split(',')

0 commit comments

Comments
 (0)