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

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: 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 899720410f8a9ce238839b1ae0e51ba74107c200..e4a0f3ec84e59a99340b6875a23062ea17b922e5 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -434,7 +434,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;

Powered by Google App Engine
This is Rietveld 408576698