Fixed bug in URL parsing.

This commit is contained in:
Vincent Richard 2004-12-26 16:42:30 +00:00
parent 3db93880fd
commit 057e8a4cfa

View File

@ -143,9 +143,16 @@ void url::parse(const string& str)
string username;
string password;
if (proto == PROTOCOL_FILE)
{
// No user name, password and host part.
slashPos = protoEnd + 3;
}
else
{
if (atPos != string::npos && atPos < slashPos)
{
const string userPart(str.begin() + protoEnd, str.begin() + atPos);
const string userPart(str.begin() + protoEnd + 3, str.begin() + atPos);
const string::size_type colonPos = userPart.find(':');
if (colonPos == string::npos)
@ -162,7 +169,8 @@ void url::parse(const string& str)
}
else
{
hostPart = string(str.begin() + protoEnd, str.begin() + slashPos);
hostPart = string(str.begin() + protoEnd + 3, str.begin() + slashPos);
}
}
// Host/port
@ -182,7 +190,7 @@ void url::parse(const string& str)
}
// Path
string path(str.begin() + slashPos, str.end());
string path = stringUtils::trim(string(str.begin() + slashPos, str.end()));
if (path == "/")
path.clear();