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

Unified Diff: net/base/net_util.cc

Issue 137233006: Support relative file paths in FilePathToFileURL(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit. Created 6 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.cc
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index f7f11a687ba096438f77ceaa1c48d9af1a28aa69..a373432a0a4f3d6e92b1cba600dd57d3bc028be7 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -998,6 +998,12 @@ GURL FilePathToFileURL(const base::FilePath& path) {
// "file://///server/path" for UNC. The URL canonicalizer will fix up the
// latter case to be the canonical UNC form: "file://server/path"
base::FilePath::StringType url_string(kFileURLPrefix);
+ if (!path.IsAbsolute()) {
+ base::FilePath current_dir;
+ PathService::Get(base::DIR_CURRENT, &current_dir);
+ url_string.append(current_dir.value());
+ url_string.push_back(base::FilePath::kSeparators[0]);
+ }
url_string.append(path.value());
// Now do replacement of some characters. Since we assume the input is a
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698