Add support for link generated by matrix.to website.

This commit is contained in:
Benoit Marty
2024-05-03 11:57:22 +02:00
parent 0d294ff171
commit b156097e1a
5 changed files with 63 additions and 2 deletions

View File

@@ -58,3 +58,15 @@ fun String.ellipsize(length: Int): String {
return "${this.take(length)}"
}
/**
* Replace the old prefix with the new prefix.
* If the string does not start with the old prefix, the string is returned as is.
*/
fun String.replacePrefix(oldPrefix: String, newPrefix: String): String {
return if (startsWith(oldPrefix)) {
newPrefix + substring(oldPrefix.length)
} else {
this
}
}