16 lines
320 B
JavaScript
16 lines
320 B
JavaScript
|
/**
|
||
|
* Gets the country code from a country:state value string.
|
||
|
*
|
||
|
* @format
|
||
|
* @param {string} countryState Country state string, e.g. US:GA.
|
||
|
* @return {string} Country string.
|
||
|
*/
|
||
|
|
||
|
export function getCountryCode( countryState ) {
|
||
|
if ( ! countryState ) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return countryState.split( ':' )[ 0 ];
|
||
|
}
|