host = url.substr(pos, pos1-pos);
pos = pos1;
}
- if ( (pos1 = host.find_first_of(":")) != std::string::npos ) {
+ if (host.at(0) == '[') { // IPv6
+ if ((pos1 = host.find_first_of("]")) == std::string::npos) {
+ // incomplete address
+ return false;
+ }
+ size_t pos2;
+ if ((pos2 = host.find_first_of(":", pos1)) != std::string::npos) {
+ std::istringstream tmp(host.substr(pos2 + 1));
+ tmp >> port;
+ }
+ host = host.substr(1, pos1 - 1);
+ } else if ( (pos1 = host.find_first_of(":")) != std::string::npos ) {
std::istringstream tmp(host.substr(pos1+1));
tmp >> port;
host = host.substr(0, pos1);