mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
3db9024a2d
* chore: update editor version * fix: export name (with CJK) doesn't match the document name * chore: bump version 0.3.1
21 lines
554 B
Dart
21 lines
554 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
extension EncodeString on String {
|
|
static const _specialCharacters = r'\/:*?"<>| ';
|
|
|
|
/// Encode a string to a file name.
|
|
///
|
|
/// Normalizes the string to remove special characters and replaces the "\/:*?"<>|" with underscores.
|
|
String toFileName() {
|
|
final buffer = StringBuffer();
|
|
for (final character in characters) {
|
|
if (_specialCharacters.contains(character)) {
|
|
buffer.write('_');
|
|
} else {
|
|
buffer.write(character);
|
|
}
|
|
}
|
|
return buffer.toString();
|
|
}
|
|
}
|