Skip to content

Instantly share code, notes, and snippets.

@mspclaims
Created January 19, 2018 00:24
Show Gist options
  • Save mspclaims/24273136d3081436083e187712d40fe3 to your computer and use it in GitHub Desktop.
Save mspclaims/24273136d3081436083e187712d40fe3 to your computer and use it in GitHub Desktop.
reformat UUID which had dashes stripped out
module.exports.restoreUUID = function(id){
if (id.length != 32) return id;
let template = "8-4-4-4-12";//using string to provide guid template
let offset = 0;
return template
.split("-")
.map(length => {
let part = id.substr(offset,length);
offset += parseInt(length);
return part;
})
.join("-");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment