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

Unified Diff: net/base/data_url.cc

Issue 338503006: Allow data urls to have a fragment part. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix review issues Created 6 years, 6 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 | « no previous file | net/base/data_url_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/data_url.cc
diff --git a/net/base/data_url.cc b/net/base/data_url.cc
index 9699136c85fd5cff3f62270b9336e35bd4d51f74..f22d5e490053dfd2f315c363e83e516f81a8f812 100644
--- a/net/base/data_url.cc
+++ b/net/base/data_url.cc
@@ -23,20 +23,18 @@ bool DataURL::Parse(const GURL& url, std::string* mime_type,
std::string* charset, std::string* data) {
DCHECK(mime_type->empty());
DCHECK(charset->empty());
- std::string::const_iterator begin = url.spec().begin();
- std::string::const_iterator end = url.spec().end();
+ DCHECK(url.SchemeIs("data"));
- std::string::const_iterator after_colon = std::find(begin, end, ':');
- if (after_colon == end)
- return false;
- ++after_colon;
+ const std::string path = url.path();
asanka 2014/08/13 15:41:41 Shall we try to avoid constructing strings? I beli
+ std::string::const_iterator begin = path.begin();
+ std::string::const_iterator end = path.end();
- std::string::const_iterator comma = std::find(after_colon, end, ',');
+ std::string::const_iterator comma = std::find(begin, end, ',');
if (comma == end)
return false;
std::vector<std::string> meta_data;
- std::string unparsed_meta_data(after_colon, comma);
+ std::string unparsed_meta_data(begin, comma);
base::SplitString(unparsed_meta_data, ';', &meta_data);
std::vector<std::string>::iterator iter = meta_data.begin();
« no previous file with comments | « no previous file | net/base/data_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698