mirror of
https://github.com/MatomoCamp/matomocamp-companion-android.git
synced 2024-09-19 16:13:46 +02:00
Don't remove underscores when transforming speaker names to URL slugs
This commit is contained in:
parent
3477fda521
commit
2e90602ba8
1 changed files with 7 additions and 3 deletions
|
@ -61,7 +61,7 @@ public class StringUtils {
|
|||
int size = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
c = source.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
if (isLetterOrDigitOrUnderscore(c)) {
|
||||
result[size++] = c;
|
||||
replaced = false;
|
||||
} else {
|
||||
|
@ -82,15 +82,19 @@ public class StringUtils {
|
|||
int st = 0;
|
||||
int len = source.length();
|
||||
|
||||
while ((st < len) && !Character.isLetterOrDigit(source.charAt(st))) {
|
||||
while ((st < len) && !isLetterOrDigitOrUnderscore(source.charAt(st))) {
|
||||
st++;
|
||||
}
|
||||
while ((st < len) && !Character.isLetterOrDigit(source.charAt(len - 1))) {
|
||||
while ((st < len) && !isLetterOrDigitOrUnderscore(source.charAt(len - 1))) {
|
||||
len--;
|
||||
}
|
||||
return ((st > 0) || (len < source.length())) ? source.substring(st, len) : source;
|
||||
}
|
||||
|
||||
private static boolean isLetterOrDigitOrUnderscore(char c) {
|
||||
return Character.isLetterOrDigit(c) || c == '_';
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a name to a slug identifier to be used in a FOSDEM URL.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue