function formatToUUID(str) {
if (str.split('-').length === 5) {
return str;
}
const r = new RegExp(/([A-Za-z0-9]{8})([A-Za-z0-9]{4})([A-Za-z0-9]{4})([A-Za-z0-9]{4})([A-Za-z0-9]{12})/gi);
const matches = r.exec(str);
if (matches.length !== 6) {
throw new Error('Invalid UUID');
}
const ret = matches.slice(1, matches.length).join('-').toLowerCase();
console.log(ret);
return ret;
}