Add tests to Twitch User/Channel name strip functions (#3568)

This commit is contained in:
pajlada
2022-02-12 15:06:47 +01:00
committed by GitHub
parent b2fa7b1d94
commit fb9c3ad42b
5 changed files with 193 additions and 26 deletions
+25
View File
@@ -10,4 +10,29 @@ void openTwitchUsercard(QString channel, QString username)
QDesktopServices::openUrl("https://www.twitch.tv/popout/" + channel +
"/viewercard/" + username);
}
void stripUserName(QString &userName)
{
if (userName.startsWith('@'))
{
userName.remove(0, 1);
}
if (userName.endsWith(','))
{
userName.chop(1);
}
}
void stripChannelName(QString &channelName)
{
if (channelName.startsWith('@') || channelName.startsWith('#'))
{
channelName.remove(0, 1);
}
if (channelName.endsWith(','))
{
channelName.chop(1);
}
}
} // namespace chatterino