87 static const std::regex re(
88 R"(^(?:(https?)://)?(?![^/]*@)((?:(?:25[0-5]|2[0-4]\d|1?\d{1,2})\.){3}(?:25[0-5]|2[0-4]\d|1?\d{1,2})|[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*)(?::([0-9]{1,5}))?([^?#]*)(\?[^#]*)?(?:#.*)?$)",
89 std::regex::ECMAScript | std::regex::icase);
92 if (std::regex_match(url, match, re)) {
99 const std::string& scheme = match[1].matched ? match[1].str() :
"http";
100 const std::string& host = match[2].str();
101 const uint16_t port = match[3].matched ?
static_cast<uint16_t>(std::stoi(match[3].str())) :
static_cast<uint16_t>(80);
102 const std::string& path = (match[4].matched ? match[4].str() :
"/");
103 const std::string& query = (match[5].matched ? match[5].str() :
"");
105 if (scheme ==
"https") {
108 LOG(ERROR) <<
"Scheme not valid: " << scheme;
111 LOG(ERROR) <<
"EventSource url not accepted: " << url;
118 if (!origin.empty() && origin.at(origin.length() - 1) ==
'/') {
122 if (!path.empty() && path.at(0) !=
'/') {
126 return EventSource(!origin.empty() ? origin + path : path);