You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

19 lines
601 B

const _ = require('lodash');
const iso3166 = require('iso3166-1');
// this sanitizer exists solely to convert an ISO2 country value to ISO3
// eg - 'TH' -> 'THA'
// this can go away once altnames imports ISO2 country values from WOF
function sanitize( raw, clean ){
// error & warning messages
const messages = { errors: [], warnings: [] };
if (clean.hasOwnProperty('parsed_text') && iso3166.is2(_.toUpper(clean.parsed_text.country))) {
clean.parsed_text.country = iso3166.to3(_.toUpper(clean.parsed_text.country));
}
return messages;
}
// export function
module.exports = sanitize;