Chromium Code Reviews| Index: services/url_response_disk_cache/url_response_disk_cache_impl.cc |
| diff --git a/services/url_response_disk_cache/url_response_disk_cache_impl.cc b/services/url_response_disk_cache/url_response_disk_cache_impl.cc |
| index 70a450a5f987f9147c4faa511c4b3798081fc17b..0ef56ca300d9d9911e31dbdd6dfb50da28d0e3ea 100644 |
| --- a/services/url_response_disk_cache/url_response_disk_cache_impl.cc |
| +++ b/services/url_response_disk_cache/url_response_disk_cache_impl.cc |
| @@ -68,6 +68,21 @@ Array<uint8_t> PathToArray(const base::FilePath& path) { |
| return result.Pass(); |
| } |
| +std::string CanonicalizeURL(const std::string& url) { |
|
ppi
2015/08/05 13:59:19
please add a comment stating that we are matching
qsr
2015/08/05 14:07:57
Done.
|
| + GURL gurl(url); |
| + |
| + if (!gurl.has_query()) { |
| + return gurl.spec(); |
| + } |
| + |
| + GURL::Replacements repl; |
| + repl.SetQueryStr(""); |
| + std::string result = gurl.ReplaceComponents(repl).spec(); |
| + // Remove the dangling '?' because it's ugly. |
| + base::ReplaceChars(result, "?", "", &result); |
| + return result; |
| +} |
| + |
| // Encode a string in ascii. This uses _ as an escape character. It also escapes |
| // ':' because it is an usual path separator, and '#' because dart refuses it in |
| // URLs. |
| @@ -95,7 +110,7 @@ base::FilePath GetDirName(base::FilePath base_directory, |
| const std::string& url) { |
| // TODO(qsr): If the speed of directory traversal is problematic, this might |
| // need to change to use less directories. |
| - return base_directory.Append(EncodeString(url)); |
| + return base_directory.Append(EncodeString(CanonicalizeURL(url))); |
| } |
| // Returns the directory that the consumer can use to cache its own data. |