Support URLs with no slash before the question mark (#507)
* Support Url No Slash Before Question Mark * Support Url No Slash Before Question Mark * unit test fix --------- Co-authored-by: Giuseppe Penone <giuseppe.penone@delonghigroup.com>
This commit is contained in:
parent
98b4828e93
commit
755d98d918
@ -180,7 +180,7 @@ namespace
|
|||||||
bHasUserName = true;
|
bHasUserName = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (*LocalString == '/')
|
else if (*LocalString == '/' || *LocalString == '?')
|
||||||
{
|
{
|
||||||
// end of <host>:<port> specification
|
// end of <host>:<port> specification
|
||||||
bHasUserName = false;
|
bHasUserName = false;
|
||||||
@ -242,7 +242,7 @@ namespace
|
|||||||
LocalString++;
|
LocalString++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (!bHasBracket && (*LocalString == ':' || *LocalString == '/'))
|
else if (!bHasBracket && (*LocalString == ':' || *LocalString == '/' || *LocalString == '?'))
|
||||||
{
|
{
|
||||||
// port number is specified
|
// port number is specified
|
||||||
break;
|
break;
|
||||||
@ -280,12 +280,14 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip '/'
|
// skip '/'
|
||||||
if (*CurrentString != '/')
|
if (*CurrentString != '/' && *CurrentString != '?')
|
||||||
{
|
{
|
||||||
return clParseURL(LUrlParserError_NoSlash);
|
return clParseURL(LUrlParserError_NoSlash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*CurrentString != '?') {
|
||||||
CurrentString++;
|
CurrentString++;
|
||||||
|
}
|
||||||
|
|
||||||
// parse the path
|
// parse the path
|
||||||
LocalString = CurrentString;
|
LocalString = CurrentString;
|
||||||
|
@ -84,6 +84,40 @@ namespace ix
|
|||||||
REQUIRE(port == 443); // default port for wss
|
REQUIRE(port == 443); // default port for wss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("wss://google.com/?arg=value")
|
||||||
|
{
|
||||||
|
std::string url = "wss://google.com/?arg=value&arg2=value2";
|
||||||
|
std::string protocol, host, path, query;
|
||||||
|
int port;
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
res = UrlParser::parse(url, protocol, host, path, query, port);
|
||||||
|
|
||||||
|
REQUIRE(res);
|
||||||
|
REQUIRE(protocol == "wss");
|
||||||
|
REQUIRE(host == "google.com");
|
||||||
|
REQUIRE(path == "/?arg=value&arg2=value2");
|
||||||
|
REQUIRE(query == "arg=value&arg2=value2");
|
||||||
|
REQUIRE(port == 443); // default port for wss
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("wss://google.com?arg=value")
|
||||||
|
{
|
||||||
|
std::string url = "wss://google.com?arg=value&arg2=value2";
|
||||||
|
std::string protocol, host, path, query;
|
||||||
|
int port;
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
res = UrlParser::parse(url, protocol, host, path, query, port);
|
||||||
|
|
||||||
|
REQUIRE(res);
|
||||||
|
REQUIRE(protocol == "wss");
|
||||||
|
REQUIRE(host == "google.com");
|
||||||
|
REQUIRE(path == "/?arg=value&arg2=value2");
|
||||||
|
REQUIRE(query == "arg=value&arg2=value2");
|
||||||
|
REQUIRE(port == 443); // default port for wss
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("real test")
|
SECTION("real test")
|
||||||
{
|
{
|
||||||
std::string url =
|
std::string url =
|
||||||
|
Loading…
Reference in New Issue
Block a user