Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Dart / Flutter package, which replaces characters in strings that are illegal/unsafe for filenames.

License

Notifications You must be signed in to change notification settings

egomobile/sanitize_filename

Repository files navigation

Dart package, which is a clone of the popular sanitize-filename npm module by Parsha Pourkhomami.

Usage

import 'package:sanitize_filename/sanitize_filename.dart';

void main() {
  const unsafeUserInput = "~/.\u0000ssh/authorized_keys";

  final safeUserInput1 = sanitizeFilename(unsafeUserInput);
  final safeUserInput2 = sanitizeFilename(unsafeUserInput, replacement: '-');

  // "~.sshauthorized_keys"
  print("safeUserInput1: $safeUserInput1");
  // "~-.-ssh-authorized_keys"
  print("safeUserInput2: $safeUserInput2");
}