const std::string schema_re = "([[:alpha:]]+:\\/\\/)";
const std::string user_pass_re = "(([^:\\s]+):([^@\\s]+)@)?";
const std::string host_port_re = "([[:alnum:].:-]+)";
- const std::string vhost_re = "(/[[:print:]]+)?";
+ const std::string path_re = "(/[[:print:]]+)?";
}
bool parse_url_authority(const std::string& url, std::string& host, std::string& user, std::string& password) {
- const std::string re = schema_re + user_pass_re + host_port_re + vhost_re;
+ const std::string re = schema_re + user_pass_re + host_port_re + path_re;
const std::regex url_regex(re, std::regex::icase);
std::smatch url_match_result;
}
bool parse_url_userinfo(const std::string& url, std::string& user, std::string& password) {
- const std::string re = schema_re + user_pass_re + host_port_re + vhost_re;
+ const std::string re = schema_re + user_pass_re + host_port_re + path_re;
const std::regex url_regex(re);
std::smatch url_match_result;
delete_all_s3_topics(zones[0], zonegroup.name)
# create s3 topics
- endpoint_address = 'amqp://127.0.0.1:7001'
+ endpoint_address = 'amqp://127.0.0.1:7001/vhost_1'
endpoint_args = 'push-endpoint='+endpoint_address+'&amqp-exchange=amqp.direct&amqp-ack-level=none'
topic_conf1 = PSTopicS3(zones[0].conn, topic_name+'_1', zonegroup.name, endpoint_args=endpoint_args)
topic_arn = topic_conf1.set_config()
std::string host;
std::string user;
std::string password;
- const std::string url = "http://user:password@example.com";
+ const std::string url = "https://user:password@example.com";
ASSERT_TRUE(parse_url_authority(url, host, user, password));
EXPECT_STREQ(host.c_str(), "example.com");
EXPECT_STREQ(user.c_str(), "user");
ASSERT_FALSE(parse_url_authority(url, host, user, password));
}
+TEST(TestURL, WithPath)
+{
+ std::string host;
+ std::string user;
+ std::string password;
+ const std::string url = "amqps://www.example.com:1234/vhost_name";
+ ASSERT_TRUE(parse_url_authority(url, host, user, password));
+}
+