Fix JID parsing

This commit is contained in:
Emmanuel Gil Peyrot authored and Florent Le Coz committed 2013-11-14 23:31:32 +01:00
1 parent 8c33a01e68
commit 83219052c3
2 files changed
+27 -7

No files matched your search

+9 -7
View File
@@ -2,18 +2,20 @@
Jid::Jid(const std::string& jid)
{
std::string::size_type at = jid.find("@");
if (at != std::string::npos)
std::string::size_type slash = jid.find('/');
if (slash != std::string::npos)
{
this->resource = jid.substr(slash + 1);
}
std::string::size_type at = jid.find('@');
if (at != std::string::npos && at < slash)
{
this->local = jid.substr(0, at);
at++;
}
else
at = 0;
std::string::size_type slash = jid.find("/", at);
if (slash != std::string::npos)
{
this->resource = jid.substr(slash + 1);
}
this->domain = jid.substr(at, slash - at);
}