mirror of
https://github.com/nextcloud/android.git
synced 2024-11-21 20:55:31 +03:00
Simplify checkInvalidCharacters
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
94b6e91909
commit
7e85d80d8e
1 changed files with 8 additions and 9 deletions
|
@ -58,17 +58,16 @@ object FileNameValidator {
|
|||
}
|
||||
|
||||
private fun checkInvalidCharacters(name: String, capability: OCCapability, context: Context): String? {
|
||||
if (capability.forbiddenFilenameCharacters.isTrue) {
|
||||
val invalidCharacter = name.find {
|
||||
it.toString().matches(reservedWindowsChars) ||
|
||||
it.toString().matches(reservedUnixChars)
|
||||
}
|
||||
if (invalidCharacter != null) {
|
||||
return context.getString(R.string.file_name_validator_error_invalid_character, invalidCharacter)
|
||||
}
|
||||
if (capability.forbiddenFilenameCharacters.isFalse) return null
|
||||
|
||||
val invalidCharacter = name.find {
|
||||
val input = it.toString()
|
||||
input.matches(reservedWindowsChars) || input.matches(reservedUnixChars)
|
||||
}
|
||||
|
||||
return null
|
||||
if (invalidCharacter == null) return null
|
||||
|
||||
return context.getString(R.string.file_name_validator_error_invalid_character, invalidCharacter)
|
||||
}
|
||||
|
||||
fun isFileHidden(name: String): Boolean = !TextUtils.isEmpty(name) && name[0] == '.'
|
||||
|
|
Loading…
Reference in a new issue