Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encodeUuid(uuidString: string): any {
const uuidRegEx = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
let uuid;
if (typeof uuidString === 'string' && uuidString.match(uuidRegEx)) {
//
// The rhea library will only serialize the the uuid with an encoding of 0x98 if the uuid property is actually
// a 16 byte buffer.
//
uuid = rheaStringToUuid(uuidString);
} else {
uuid = uuidString;
}
return uuid;
}