{
result r = E_SUCCESS;
int curIndex = startSsp;
-// bool isServerAuth;
String tempPath;
String queSharp(L"?#");
String doubleSlash(L"//");
- bool startsWith = str.StartsWith(doubleSlash, curIndex);
-
int position = 0;
bool isPath = false;
- int temp = 0;
+ int temp = -1;
+
+ bool startsWith = str.StartsWith(doubleSlash, curIndex);
if (startsWith)
{
curIndex += 2;
-// int indexOf;
String special(L"/?#");
-
int index = Scan(str, curIndex, special);
- if (index > (int) curIndex)
+ if (index > curIndex)
{
r = str.SubString(curIndex, index - curIndex, authority);
if (IsFailed(r))
{
goto CATCH;
}
-
- //bool isServer;
- //r = ParseAuthority(str, curIndex, isServer);
- //if (IsFailed(r)) goto CATCH;
}
- else if (index < (int) str.GetLength())
- {
- // allow an empty authority
-// authority = String::Empty();
- // empty statement
- }
- else
+ else if (index >= str.GetLength())
{
r = E_INVALID_FORMAT;
goto CATCH;
}
+
curIndex += authority.GetLength();
+ if (curIndex == str.GetLength())
+ {
+ r = E_SUCCESS;
+ goto CATCH;
+ }
}
- r = queSharp.IndexOf(str[0], 0, temp);
- if (r == E_SUCCESS)
+ queSharp.IndexOf(str[0], 0, temp);
+ if (temp >= 0)
{
position = 0;
}
else
{
- position = Scan(str, curIndex, queSharp); // may be empty
- if (position < 0)
- {
- r = E_INVALID_FORMAT;
- goto CATCH;
- }
+ position = Scan(str, curIndex, queSharp);
- if (position == curIndex)
+ if (position == curIndex && authority.GetLength() == 0)
{
- // There is no path and query
- r = E_SUCCESS;
+ // If both authority and path are empty, it returns error.
+ r = E_INVALID_FORMAT;
goto CATCH;
}
-
}
r = str.SubString(curIndex, position - curIndex, tempPath);