ImbaCow / OOP

Repo for object oriented programming
0 stars 0 forks source link

Замечания по URLParser #11

Open alexey-malov opened 5 years ago

alexey-malov commented 5 years ago
bool ParseURL(const std::string& url, Protocol& protocol, int& port, std::string& host, std::string& document)
{
    std::string regexStr = (boost::format(URL_REGEX_PATTERN) % PROTOCOL_REGEX % HOST_REGEX % PORT_REGEX % PATH_REGEX).str();
    std::regex reg(regexStr, std::regex_constants::icase);
    std::cmatch match;
    if (std::regex_match(url.c_str(), match, reg))
alexey-malov commented 5 years ago
    if (port < MIN_PORT || port > MAX_PORT)
    {
        throw std::out_of_range("Port must be in range " + std::to_string(MIN_PORT) + "-" + std::to_string(MAX_PORT) + ", '" + str + "' given");
    }
alexey-malov commented 5 years ago