Skip to content
Snippets Groups Projects
Verified Commit a48008d5 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Improve performance and clarity of hostmask splitter

parent bb25a14c
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -20,20 +20,15 @@
package de.kuschku.libquassel.util.irc
object HostmaskHelper {
fun nick(mask: String): String {
val (nick, _, _) = split(mask)
return nick
}
fun nick(mask: String) = mask
.substringBefore('!', missingDelimiterValue = mask)
fun user(mask: String): String {
val (_, user, _) = split(mask)
return user
}
fun user(mask: String) = mask
.substringBeforeLast('@', missingDelimiterValue = mask)
.substringAfter('!', missingDelimiterValue = "")
fun host(mask: String): String {
val (_, _, host) = split(mask)
return host
}
fun host(mask: String) = mask
.substringAfterLast('@', missingDelimiterValue = "")
fun split(mask: String): Triple<String, String, String> {
val userPartHostSplit = mask.split("@", limit = 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment