新增url判空逻辑

This commit is contained in:
xiongziliang 2022-05-29 21:36:34 +08:00
parent 4f05aef245
commit ea6ef2779e

View File

@ -212,6 +212,7 @@ static void inline checkHost(std::string &host) {
} }
void splitUrl(const std::string &url, std::string &host, uint16_t &port) { void splitUrl(const std::string &url, std::string &host, uint16_t &port) {
CHECK(!url.empty(), "empty url");
auto pos = url.rfind(':'); auto pos = url.rfind(':');
if (pos == string::npos || url.back() == ']') { if (pos == string::npos || url.back() == ']') {
//没有冒号,未指定端口;或者是纯粹的ipv6地址 //没有冒号,未指定端口;或者是纯粹的ipv6地址