sanitize_filename 1.0.5 copy "sanitize_filename: ^1.0.5" to clipboard
sanitize_filename: ^1.0.5 copied to clipboard

Replaces characters in strings that are illegal/unsafe for filenames.

example/sanitize_filename_example.dart

// This file is part of the sanitize_filename distribution.
// Copyright (c) Next.e.GO Mobile SE, Aachen, Germany (https://e-go-mobile.com/)
//
// sanitize_filename is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, version 3.
//
// sanitize_filename is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

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");
}
7
likes
140
pub points
85%
popularity

Publisher

verified publishere-go-mobile.de

Replaces characters in strings that are illegal/unsafe for filenames.

Repository (GitHub)
View/report issues

Documentation

API reference

License

LGPL-3.0 (LICENSE)

More

Packages that depend on sanitize_filename