ice.fo.utils
Version:
24 lines (20 loc) • 463 B
JavaScript
import formatStringBlocks from './formatStringBlocks';
/**
* Format Korean Tel
*/
export default function formatTelText(text) {
let blocks = [];
const delimiters = '-';
if (text.startsWith('02')) {
if (text.length >= 10) {
blocks = [2, 4, 4];
} else {
blocks = [2, 3, 4];
}
} else if (text.length >= 11) {
blocks = [3, 4, 4];
} else {
blocks = [3, 3, 4];
}
return formatStringBlocks(text, blocks, delimiters);
}