Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Strip unsafe characters from filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
redsolver committed Mar 13, 2021
1 parent efd6c1c commit 7f006ee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bin/yt_splitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,11 @@ String renderDuration(int x) {
}

String stripUnsafeCharacters(String text) {
return text.trim().replaceAll(RegExp(r'\|\/\\\?":\*<>'), '_');
if (Platform.isLinux) {
return text.trim().replaceAll('/', '_');
} else if (Platform.isMacOS) {
return text.trim().replaceAll(RegExp(r'[\/:]'), '_');
} else {
return text.trim().replaceAll(RegExp(r'[\|\/\\\?":\*<>]'), '_');
}
}

0 comments on commit 7f006ee

Please sign in to comment.