17 const string& expectedScheme,
18 const string& expectedPath,
19 const string& expectedQuery,
20 const string& expectedHost,
22 const string& expectedAuthority,
23 const bool expectedValid =
true) {
54 testParseURL(
"http://localhost:80/foo?bar#qqq",
"http",
"/foo",
"bar",
55 "localhost", 80,
"localhost:80");
56 testParseURL(
"http://localhost:80/foo?bar",
"http",
"/foo",
"bar",
57 "localhost", 80,
"localhost:80");
58 testParseURL(
"http://localhost:80/foo",
"http",
"/foo",
"",
59 "localhost", 80,
"localhost:80");
61 "localhost", 80,
"localhost:80");
63 "localhost", 80,
"localhost:80");
65 "localhost", 0,
"localhost");
66 testParseURL(
"http://[2401:db00:2110:3051:face:0:3f:0]/",
"http",
"/",
"",
67 "[2401:db00:2110:3051:face:0:3f:0]", 0,
68 "[2401:db00:2110:3051:face:0:3f:0]");
72 testParseURL(
"https://localhost:80/foo?bar#qqq",
"https",
"/foo",
"bar",
73 "localhost", 80,
"localhost:80");
74 testParseURL(
"rtmp://localhost:80/foo?bar#qqq",
"rtmp",
"/foo",
"bar",
75 "localhost", 80,
"localhost:80");
76 testParseURL(
"ftp://localhost:80/foo?bar#qqq",
"ftp",
"/foo",
"bar",
77 "localhost", 80,
"localhost:80");
78 testParseURL(
"proxygen://localhost:80/foo?bar#qqq",
"proxygen",
"/foo",
"bar",
79 "localhost", 80,
"localhost:80");
80 testParseURL(
"test://localhost:80/foo?bar#qqq",
"test",
"/foo",
"bar",
81 "localhost", 80,
"localhost:80");
85 testParseURL(
"test123://localhost:80",
"",
"",
"",
"", 0,
"",
false);
86 testParseURL(
"test.1://localhost:80",
"",
"",
"",
"", 0,
"",
false);
87 testParseURL(
"://localhost:80",
"",
"",
"",
"", 0,
"",
false);
88 testParseURL(
"123://localhost:80",
"",
"",
"",
"", 0,
"",
false);
89 testParseURL(
"---://localhost:80",
"",
"",
"",
"", 0,
"",
false);
93 testParseURL(
"localhost:80/foo?bar#qqq",
"",
"/foo",
"bar",
94 "localhost", 80,
"localhost:80");
96 "localhost", 80,
"localhost:80");
98 "localhost", 80,
"localhost:80");
100 "localhost", 80,
"localhost:80");
102 "localhost", 80,
"localhost:80");
104 "localhost", 0,
"localhost");
109 "/foo",
"bar",
"1.2.3.4", 54321,
"1.2.3.4:54321");
110 testParseURL(
"[::1]:80/foo?bar",
"",
"/foo",
"bar",
"[::1]", 80,
"[::1]:80");
111 testParseURL(
"[::1]/foo?bar",
"",
"/foo",
"bar",
"[::1]", 0,
"[::1]");
115 testParseURL(
"/f/o/o?bar#qqq",
"",
"/f/o/o",
"bar",
"", 0,
"");
116 testParseURL(
"/f/o/o?bar",
"",
"/f/o/o",
"bar",
"", 0,
"");
125 testParseURL(
"/?ids=http://vlc.afreecodec.com/download/",
"",
126 "/",
"ids=http://vlc.afreecodec.com/download/",
"", 0,
"");
127 testParseURL(
"/plugins/facepile.php?href=http://www.vakan.nl/hotels",
128 "",
"/plugins/facepile.php",
129 "href=http://www.vakan.nl/hotels",
"", 0,
"");
133 testParseURL(
"http://tel:198433511/",
"",
"",
"",
"", 0,
"",
false);
134 testParseURL(
"localhost:80/foo#bar?qqq",
"",
"",
"",
"", 0,
"",
false);
137 testParseURL(
"[::1/foo?bar",
"",
"",
"",
"", 0,
"",
false);
139 testParseURL(
"http://tel:198433511/test\n",
"",
"",
"",
"", 0,
"",
false);
std::string authority() const
void testParseURL(const string &url, const string &expectedScheme, const string &expectedPath, const string &expectedQuery, const string &expectedHost, const uint16_t expectedPort, const string &expectedAuthority, const bool expectedValid=true)
folly::StringPiece query() const
void testHostIsIpAddress(const string &url, const bool expected)
folly::StringPiece url() const
#define EXPECT_EQ(val1, val2)
folly::StringPiece hostNoBrackets()
TEST(ParseURL, HostNoBrackets)
folly::StringPiece host() const
folly::StringPiece path() const
folly::StringPiece scheme() const