mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
fix(radio): canonicalize priority country aliases before querying
This commit is contained in:
1 parent
aff540ad39
commit
94e4c2176e
4 files changed
+36
-4
No files matched your search
@@ -39,12 +39,14 @@ export function parseRadioPriorityCountries(value = '') {
|
||||
const entries = Array.isArray(value) ? value : String(value).split(',');
|
||||
const countries = [];
|
||||
for (const entry of entries) {
|
||||
const code = String(entry).trim().toUpperCase();
|
||||
if (!code) continue;
|
||||
if (!/^[A-Z]{2}$/.test(code) || !normalizeRadioCountryInput(code).valid)
|
||||
const input = String(entry).trim().toUpperCase();
|
||||
if (!input) continue;
|
||||
const normalized = normalizeRadioCountryInput(input);
|
||||
if (!/^[A-Z]{2}$/.test(input) || !normalized.valid)
|
||||
throw new TypeError(
|
||||
'RADIO_PRIORITY_COUNTRIES requires ISO alpha-2 country codes',
|
||||
);
|
||||
const code = normalized.code;
|
||||
if (!countries.includes(code)) countries.push(code);
|
||||
}
|
||||
if (countries.length > PRIORITY_COUNTRY_LIMIT)
|
||||
|
||||
Reference in new issue
Block a user