Commit 6e687056 authored by Jonas Waeber's avatar Jonas Waeber
Browse files
parent a5d29720
Pipeline #8744 passed with stages
in 5 minutes and 10 seconds
......@@ -20,12 +20,12 @@ package org.memobase.helpers
object StringHelpers {
private val whitespace = Regex("\\s+")
private val illegalCharacters = Regex("\\s*[/?@\\[\\]:#]+\\s*")
private val illegalCharacters = Regex("\\s*[/?@\\[\\]:#.]+\\s*")
fun normalizeId(value: String): String {
return value
.trim()
.replace(illegalCharacters, "-")
.replace(illegalCharacters, "_")
.replace(whitespace, "_")
}
}
\ No newline at end of file
......@@ -170,9 +170,9 @@ class Tests {
private fun idExamples() = Stream.of(
Pair("J2.143#1996/386#414-3#1*", "J2.143-1996-386-414-3-1*"),
Pair(" IB Becker Audiovisuals / 2", "IB_Becker_Audiovisuals-2"),
Pair("J2.143#1996/386#414-3#1*", "J2_143_1996_386_414-3_1*"),
Pair(" IB Becker Audiovisuals-2", "IB_Becker_Audiovisuals-2"),
Pair(" oisadi ", "oisadi"),
Pair("Test mit vielen spaces . jal", "Test_mit_vielen_spaces_._jal")
Pair("Test mit vielen spaces . jal", "Test_mit_vielen_spaces_jal")
)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment