diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-15 18:37:11 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-15 18:37:11 +0000 |
commit | 3130a853b69a63f159d9d3e74395eb9332f6bfad (patch) | |
tree | d2f6a28bb8b7be7aa112acaa4620eda84e5fcc4e /net/http/http_util_unittest.cc | |
parent | 3dd1f6d55213a0c14590d5db0236b5472d2adfab (diff) | |
download | chromium_src-3130a853b69a63f159d9d3e74395eb9332f6bfad.zip chromium_src-3130a853b69a63f159d9d3e74395eb9332f6bfad.tar.gz chromium_src-3130a853b69a63f159d9d3e74395eb9332f6bfad.tar.bz2 |
Address a TODO for properly stripping references from request URL.
(rfind of # isn't quite right, as reference might contain hashes).
Review URL: http://codereview.chromium.org/2827
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_util_unittest.cc')
-rw-r--r-- | net/http/http_util_unittest.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/net/http/http_util_unittest.cc b/net/http/http_util_unittest.cc index 14c7724..a531228 100644 --- a/net/http/http_util_unittest.cc +++ b/net/http/http_util_unittest.cc @@ -412,3 +412,35 @@ TEST(HttpUtilTest, AssembleRawHeaders) { } } +// Test SpecForRequest() and PathForRequest(). +TEST(HttpUtilTest, RequestUrlSanitize) { + struct { + const char* url; + const char* expected_spec; + const char* expected_path; + } tests[] = { + { // Check that #hash is removed. + "http://www.google.com:78/foobar?query=1#hash", + "http://www.google.com:78/foobar?query=1", + "/foobar?query=1" + }, + { // The reference may itself contain # -- strip all of it. + "http://192.168.0.1?query=1#hash#10#11#13#14", + "http://192.168.0.1/?query=1", + "/?query=1" + }, + { // Strip username/password. + "http://user:pass@google.com", + "http://google.com/", + "/" + } + }; + for (size_t i = 0; i < arraysize(tests); ++i) { + GURL url(GURL(tests[i].url)); + std::string expected_spec(tests[i].expected_spec); + std::string expected_path(tests[i].expected_path); + + EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url)); + EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url)); + } +} |