sanitizeKey static method

String sanitizeKey(
  1. String key
)

Maps an arbitrary key (e.g. <user>@<node>) to a safe, stable identifier component — usable as a filename (CLI) or a storage-key suffix (web).

Implementation

static String sanitizeKey(String key) {
  final safe = key.replaceAll(RegExp(r'[^A-Za-z0-9_.@-]'), '_');
  return safe.isEmpty ? '_' : safe;
}