Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1005)

Unified Diff: url/gurl_unittest.cc

Issue 185133005: Move referrer stripping into GURL::GetAsReferrer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore the behavior of setting the referrer when it's invalid in URLRequest::SetReferrer. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/gurl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl_unittest.cc
diff --git a/url/gurl_unittest.cc b/url/gurl_unittest.cc
index c2d86e93ba2234d18399b5f7ad91f340ff3c2a0d..738f2cc3ecda90bf12bbbaa05791f1b5038fc138 100644
--- a/url/gurl_unittest.cc
+++ b/url/gurl_unittest.cc
@@ -287,6 +287,25 @@ TEST(GURLTest, GetOrigin) {
}
}
+TEST(GURLTest, GetAsReferrer) {
+ struct TestCase {
+ const char* input;
+ const char* expected;
+ } cases[] = {
+ {"http://www.google.com", "http://www.google.com/"},
+ {"http://user:pass@www.google.com:21/blah#baz", "http://www.google.com:21/blah"},
+ {"http://user@www.google.com", "http://www.google.com/"},
+ {"http://:pass@www.google.com", "http://www.google.com/"},
+ {"http://:@www.google.com", "http://www.google.com/"},
+ {"http://www.google.com/temp/foo?q#b", "http://www.google.com/temp/foo?q"},
+ };
+ for (size_t i = 0; i < ARRAYSIZE(cases); i++) {
+ GURL url(cases[i].input);
+ GURL origin = url.GetAsReferrer();
+ EXPECT_EQ(cases[i].expected, origin.spec());
+ }
+}
+
TEST(GURLTest, GetWithEmptyPath) {
struct TestCase {
const char* input;
« no previous file with comments | « url/gurl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698