enlargeUUID static method

String enlargeUUID(
  1. String shortId,
  2. Translator translator
)

Translate back to hex and turn back into UUID format, adding dashes.

Passes shortId to the translator function to be expanded to hex. Dashes are then added to construct a standard uuid string and the resulting String is returned.

Implementation

static String enlargeUUID(String shortId, Translator translator) {
  final uu1 = translator(shortId).padLeft(32, '0');

  // Join the zero padding and the UUID and then slice it up with match
  final m = RegExp(r'(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})').firstMatch(uu1);

  // Accumulate the matches and join them.
  return [m![1], m[2], m[3], m[4], m[5]].join('-');
}