File tree Expand file tree Collapse file tree 1 file changed +8
-20
lines changed
common/src/main/kotlin/com/lambda/util Expand file tree Collapse file tree 1 file changed +8
-20
lines changed Original file line number Diff line number Diff line change 11package com.lambda.util
22
33object StringUtils {
4+ /* *
5+ * Returns a sanitized file path for both Unix and Linux systems
6+ */
47 fun String.sanitizeForFilename () =
5- replace(" \\ " , " _" )
6- .replace(" /" , " _" )
7- .replace(" :" , " _" )
8- .replace(" *" , " _" )
9- .replace(" ?" , " _" )
10- .replace(" \" " , " _" )
11- .replace(" <" , " _" )
12- .replace(" >" , " _" )
13- .replace(" |" , " _" )
8+ replace(Regex (" [\\\\ /:*?\" <>|]" ), " _" )
149 .trim()
1510 .take(255 ) // truncate to 255 characters for Windows compatibility
1611
17- // ToDo: Fix this. Does not work for some reason
18- // fun String.sanitizeForFilename(): String {
19- // val invalidChars = Regex.fromLiteral("[\\\\/*?|<>:\"\\[\\]\\(\\)\\s]")
20- // val safeChars = Regex.fromLiteral("[^\\p{L}\\p{N}_\\-~]")
21- // return replace(invalidChars, "_")
22- // .replace(safeChars, "")
23- // .trim()
24- // .take(255) // truncate to 255 characters for Windows compatibility
25- // }
26-
2712
13+ /* *
14+ * Capitalizes the first character of a string using its Unicode mapping
15+ */
2816 fun String.capitalize () = replaceFirstChar { it.titlecase() }
2917
3018 /* *
@@ -84,4 +72,4 @@ object StringUtils {
8472
8573 return cost[len0 - 1 ]
8674 }
87- }
75+ }
You can’t perform that action at this time.
0 commit comments