@@ -81,6 +81,52 @@ TEST_F(URLTest, Base3) { |
81 | 81 | EXPECT_EQ(simple.path(), "/baz"); |
82 | 82 | } |
83 | 83 |
|
| 84 | +TEST_F(URLTest, Base4) { |
| 85 | + const char* input = "\\x"; |
| 86 | + const char* base = "http://example.org/foo/bar"; |
| 87 | + |
| 88 | + URL simple(input, strlen(input), base, strlen(base)); |
| 89 | + |
| 90 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); |
| 91 | + EXPECT_EQ(simple.protocol(), "http:"); |
| 92 | + EXPECT_EQ(simple.host(), "example.org"); |
| 93 | + EXPECT_EQ(simple.path(), "/x"); |
| 94 | +} |
| 95 | + |
| 96 | +TEST_F(URLTest, Base5) { |
| 97 | + const char* input = "/x"; |
| 98 | + const char* base = "http://example.org/foo/bar"; |
| 99 | + |
| 100 | + URL simple(input, strlen(input), base, strlen(base)); |
| 101 | + |
| 102 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); |
| 103 | + EXPECT_EQ(simple.protocol(), "http:"); |
| 104 | + EXPECT_EQ(simple.host(), "example.org"); |
| 105 | + EXPECT_EQ(simple.path(), "/x"); |
| 106 | +} |
| 107 | + |
| 108 | +TEST_F(URLTest, Base6) { |
| 109 | + const char* input = "\\\\x"; |
| 110 | + const char* base = "http://example.org/foo/bar"; |
| 111 | + |
| 112 | + URL simple(input, strlen(input), base, strlen(base)); |
| 113 | + |
| 114 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); |
| 115 | + EXPECT_EQ(simple.protocol(), "http:"); |
| 116 | + EXPECT_EQ(simple.host(), "x"); |
| 117 | +} |
| 118 | + |
| 119 | +TEST_F(URLTest, Base7) { |
| 120 | + const char* input = "//x"; |
| 121 | + const char* base = "http://example.org/foo/bar"; |
| 122 | + |
| 123 | + URL simple(input, strlen(input), base, strlen(base)); |
| 124 | + |
| 125 | + EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED); |
| 126 | + EXPECT_EQ(simple.protocol(), "http:"); |
| 127 | + EXPECT_EQ(simple.host(), "x"); |
| 128 | +} |
| 129 | + |
84 | 130 | TEST_F(URLTest, TruncatedAfterProtocol) { |
85 | 131 | char input[2] = { 'q', ':' }; |
86 | 132 | URL simple(input, sizeof(input)); |
|