OLD | NEW |
1 // Copyright 2007, Google Inc. | 1 // Copyright 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 // reasonable to do. | 2025 // reasonable to do. |
2026 {"http://host/a", true, false, "\\\\Another\\path", true, true, true, "http:
//another/path"}, | 2026 {"http://host/a", true, false, "\\\\Another\\path", true, true, true, "http:
//another/path"}, |
2027 #endif | 2027 #endif |
2028 // Even on Windows, we don't allow relative drive specs when the base | 2028 // Even on Windows, we don't allow relative drive specs when the base |
2029 // is not file. | 2029 // is not file. |
2030 {"http://host/a", true, false, "/c:\\foo", true, true, true, "http://host/c:
/foo"}, | 2030 {"http://host/a", true, false, "/c:\\foo", true, true, true, "http://host/c:
/foo"}, |
2031 {"http://host/a", true, false, "//c:\\foo", true, true, true, "http://c/foo"
}, | 2031 {"http://host/a", true, false, "//c:\\foo", true, true, true, "http://c/foo"
}, |
2032 // Filesystem URL tests; filesystem URLs are only valid and relative if | 2032 // Filesystem URL tests; filesystem URLs are only valid and relative if |
2033 // they have no scheme, e.g. "./index.html". There's no valid equivalent | 2033 // they have no scheme, e.g. "./index.html". There's no valid equivalent |
2034 // to http:index.html. | 2034 // to http:index.html. |
| 2035 #ifdef FULL_FILESYSTEM_URL_SUPPORT |
2035 {"filesystem:http://host/t/path", true, false, "filesystem:http://host/t/pat
h2", true, false, false, NULL}, | 2036 {"filesystem:http://host/t/path", true, false, "filesystem:http://host/t/pat
h2", true, false, false, NULL}, |
2036 {"filesystem:http://host/t/path", true, false, "filesystem:https://host/t/pa
th2", true, false, false, NULL}, | 2037 {"filesystem:http://host/t/path", true, false, "filesystem:https://host/t/pa
th2", true, false, false, NULL}, |
2037 {"filesystem:http://host/t/path", true, false, "http://host/t/path2", true,
false, false, NULL}, | 2038 {"filesystem:http://host/t/path", true, false, "http://host/t/path2", true,
false, false, NULL}, |
2038 {"http://host/t/path", true, false, "filesystem:http://host/t/path2", true,
false, false, NULL}, | 2039 {"http://host/t/path", true, false, "filesystem:http://host/t/path2", true,
false, false, NULL}, |
2039 {"filesystem:http://host/t/path", true, false, "./path2", true, true, true,
"filesystem:http://host/t/path2"}, | 2040 {"filesystem:http://host/t/path", true, false, "./path2", true, true, true,
"filesystem:http://host/t/path2"}, |
2040 {"filesystem:http://host/t/path/", true, false, "path2", true, true, true, "
filesystem:http://host/t/path/path2"}, | 2041 {"filesystem:http://host/t/path/", true, false, "path2", true, true, true, "
filesystem:http://host/t/path/path2"}, |
2041 {"filesystem:http://host/t/path", true, false, "filesystem:http:path2", true
, false, false, NULL}, | 2042 {"filesystem:http://host/t/path", true, false, "filesystem:http:path2", true
, false, false, NULL}, |
| 2043 #endif |
2042 }; | 2044 }; |
2043 | 2045 |
2044 for (size_t i = 0; i < ARRAYSIZE(rel_cases); i++) { | 2046 for (size_t i = 0; i < ARRAYSIZE(rel_cases); i++) { |
2045 const RelativeCase& cur_case = rel_cases[i]; | 2047 const RelativeCase& cur_case = rel_cases[i]; |
2046 | 2048 |
2047 url_parse::Parsed parsed; | 2049 url_parse::Parsed parsed; |
2048 int base_len = static_cast<int>(strlen(cur_case.base)); | 2050 int base_len = static_cast<int>(strlen(cur_case.base)); |
2049 if (cur_case.is_base_file) | 2051 if (cur_case.is_base_file) |
2050 url_parse::ParseFileURL(cur_case.base, base_len, &parsed); | 2052 url_parse::ParseFileURL(cur_case.base, base_len, &parsed); |
2051 else if (cur_case.is_base_hier) | 2053 else if (cur_case.is_base_hier) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 url_canon::StdStringCanonOutput repl_output(&repl_str); | 2126 url_canon::StdStringCanonOutput repl_output(&repl_str); |
2125 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed)
; | 2127 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed)
; |
2126 repl_output.Complete(); | 2128 repl_output.Complete(); |
2127 | 2129 |
2128 // Generate the expected string and check. | 2130 // Generate the expected string and check. |
2129 std::string expected("file:///foo?"); | 2131 std::string expected("file:///foo?"); |
2130 for (size_t i = 0; i < new_query.length(); i++) | 2132 for (size_t i = 0; i < new_query.length(); i++) |
2131 expected.push_back('a'); | 2133 expected.push_back('a'); |
2132 EXPECT_TRUE(expected == repl_str); | 2134 EXPECT_TRUE(expected == repl_str); |
2133 } | 2135 } |
OLD | NEW |