boost::cmatch match;
if (UNLIKELY(!boost::regex_match(str.begin(), str.end(), match, uriRegex))) {
- throw std::invalid_argument("invalid URI");
+ throw std::invalid_argument(to<std::string>("invalid URI ", str));
}
scheme_ = submatch(match, 1);
authority.second,
authorityMatch,
authorityRegex)) {
- throw std::invalid_argument("invalid URI authority");
+ throw std::invalid_argument(
+ to<std::string>("invalid URI authority ",
+ StringPiece(authority.first, authority.second)));
}
StringPiece port(authorityMatch[4].first, authorityMatch[4].second);
#include "folly/Uri.h"
+#include <boost/algorithm/string.hpp>
#include <glog/logging.h>
#include <gtest/gtest.h>
EXPECT_EQ(s, u.fbstr());
}
- EXPECT_THROW({Uri("2http://www.facebook.com/");},
- std::invalid_argument);
+ {
+ fbstring s("2http://www.facebook.com");
+
+ try {
+ Uri u(s);
+ CHECK(false) << "Control should not have reached here";
+ } catch (const std::invalid_argument& ex) {
+ EXPECT_TRUE(boost::algorithm::ends_with(ex.what(), s));
+ }
+ }
+
+ {
+ fbstring s("www[facebook]com");
+
+ try {
+ Uri u("http://" + s);
+ CHECK(false) << "Control should not have reached here";
+ } catch (const std::invalid_argument& ex) {
+ EXPECT_TRUE(boost::algorithm::ends_with(ex.what(), s));
+ }
+ }
}