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

Unified Diff: chrome/common/extensions/extension.cc

Issue 10384072: Update to handle absolute-looking paths in manifests and still produce nice-looking URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 7 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
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 92236ff4fcd696a35372cacf06a2291014eb6272..b541a154bc47c74d9c61a129b160b7bd3872a8af 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -435,7 +435,15 @@ GURL Extension::GetResourceURL(const GURL& extension_url,
DCHECK(extension_url.SchemeIs(chrome::kExtensionScheme));
DCHECK_EQ("/", extension_url.path());
- GURL ret_val = GURL(extension_url.spec() + relative_path);
+ std::string path = relative_path;
+
+ // If the relative path starts with "/", it is "absolute" relative to the
+ // extension base directory, but extension_url is already specified to refer
+ // to that base directory, so strip the leading "/" if present.
+ if (relative_path.size() > 0 && relative_path[0] == '/')
+ path = relative_path.substr(1);
+
+ GURL ret_val = GURL(extension_url.spec() + path);
DCHECK(StartsWithASCII(ret_val.spec(), extension_url.spec(), false));
return ret_val;
« no previous file with comments | « chrome/browser/intents/web_intents_registry_unittest.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698