1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-18 11:41:21 +02:00

Folder names remain closer to their original name. Fixes #1258

This commit is contained in:
xuxuck
2020-08-12 14:37:09 +02:00
committed by soloturn
parent 254f9eafbd
commit 8609f68f25

View File

@@ -486,8 +486,15 @@ public class Utils {
return text;
}
/**
* Removes any potentially unsafe characters from a string and truncates it on a maximum length of 100 characters.
* Characters considered safe are alpha numerical characters as well as minus, dot, comma, underscore and whitespace.
*
* @param text The potentially unsafe text
* @return a filesystem safe string
*/
public static String filesystemSafe(String text) {
text = text.replaceAll("[^a-zA-Z0-9.-]", "_").replaceAll("__", "_").replaceAll("_+$", "");
text = text.replaceAll("[^a-zA-Z0-9-.,_ ]", "");
if (text.length() > 100) {
text = text.substring(0, 99);
}