mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-04 16:35:08 -05:00
* make sure there's no double spaces left behind after stripping illegal characters
This commit is contained in:
parent
03db21ff20
commit
0b4730f070
@ -54,7 +54,6 @@ String.metaClass.getNameWithoutExtension = { getNameWithoutExtension(delegate) }
|
||||
String.metaClass.getExtension = { getExtension(delegate) }
|
||||
String.metaClass.hasExtension = { String... ext -> hasExtension(delegate, ext) }
|
||||
String.metaClass.validateFileName = { validateFileName(delegate) }
|
||||
String.metaClass.validateFilePath = { validateFilePath(delegate) }
|
||||
|
||||
// helper for enforcing filename length limits, e.g. truncate filename but keep extension
|
||||
String.metaClass.truncateFileName = { int limit = 255 -> def ext = getExtension(delegate); def name = getNameWithoutExtension(delegate); return name.substring(0, Math.min(limit - (ext ? 1+ext.length() : 0), name.length())) + (ext ? '.'+ext : '') }
|
||||
|
@ -471,7 +471,7 @@ public final class FileUtilities {
|
||||
*/
|
||||
public static String validateFileName(CharSequence filename) {
|
||||
// strip invalid characters from file name
|
||||
return ILLEGAL_CHARACTERS.matcher(filename).replaceAll("").trim();
|
||||
return ILLEGAL_CHARACTERS.matcher(filename).replaceAll("").replaceAll("\\s+", " ").trim();
|
||||
}
|
||||
|
||||
public static boolean isInvalidFileName(CharSequence filename) {
|
||||
|
Loading…
Reference in New Issue
Block a user