Improve Special Character Remover

This commit is contained in:
shabinder 2021-09-26 13:43:59 +05:30
parent 73bd43d23c
commit 9add1dd88c
2 changed files with 2 additions and 40 deletions

View File

@ -82,7 +82,7 @@ jobs:
draft: true
allowUpdates: true
tag: "v3.3.1"
artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*,android/build/outputs/apk/release/*"
artifacts: "desktop/build/compose/jars/*.jar,desktop/build/compose/binaries/main/*/*,android/build/outputs/apk/release/*signed.apk"
token: ${{ secrets.GH_TOKEN }}

View File

@ -1,7 +1,5 @@
package com.shabinder.common.utils
import io.github.shabinder.TargetPlatforms
import io.github.shabinder.activePlatform
import kotlinx.serialization.json.Json
import kotlin.native.concurrent.ThreadLocal
@ -17,41 +15,5 @@ val globalJson by lazy {
* Removing Illegal Chars from File Name
* **/
fun removeIllegalChars(fileName: String): String {
if (activePlatform is TargetPlatforms.Js) return fileName
val illegalCharArray = charArrayOf(
'/',
'\n',
'\r',
'\t',
'\u0000',
'\u000C',
'`',
'?',
'*',
'\\',
'<',
'>',
'|',
'\"',
'.',
'-',
'\''
)
var name = fileName
for (c in illegalCharArray) {
name = fileName.replace(c, '_')
}
name = name.replace("\\s".toRegex(), "_")
name = name.replace("/".toRegex(), "_")
name = name.replace("\\)".toRegex(), "")
name = name.replace("\\(".toRegex(), "")
name = name.replace("\\[".toRegex(), "")
name = name.replace("]".toRegex(), "")
name = name.replace("\\.".toRegex(), "")
name = name.replace("\"".toRegex(), "")
name = name.replace("\'".toRegex(), "")
name = name.replace(":".toRegex(), "")
name = name.replace("\\|".toRegex(), "")
return name
return fileName.replace("[^\\dA-Za-z_]".toRegex(), "_")
}