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

Unified Diff: Source/devtools/front_end/Runtime.js

Issue 475073002: DevTools: normalize sourceURL paths in importScript function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Source/devtools/front_end/common/ParsedURL.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/Runtime.js
diff --git a/Source/devtools/front_end/Runtime.js b/Source/devtools/front_end/Runtime.js
index 532aa3600f66eb1a57600f7f98c70e696b5a5d53..b9e6fc01bd5fa8a256863952e47576ef939ea6c1 100644
--- a/Source/devtools/front_end/Runtime.js
+++ b/Source/devtools/front_end/Runtime.js
@@ -47,6 +47,39 @@ function loadResource(url)
return xhr.responseText;
}
+
+/**
+ * http://tools.ietf.org/html/rfc3986#section-5.2.4
+ * @param {string} path
+ * @return {string}
+ */
+function normalizePath(path)
+{
+ if (path.indexOf("..") === -1 && path.indexOf('.') === -1)
+ return path;
+
+ var normalizedSegments = [];
+ var segments = path.split("/");
+ for (var i = 0; i < segments.length; i++) {
+ var segment = segments[i];
+ if (segment === ".")
+ continue;
+ else if (segment === "..")
+ normalizedSegments.pop();
+ else if (segment)
+ normalizedSegments.push(segment);
+ }
+ var normalizedPath = normalizedSegments.join("/");
+ if (normalizedPath[normalizedPath.length - 1] === "/")
+ return normalizedPath;
+ if (path[0] === "/" && normalizedPath)
+ normalizedPath = "/" + normalizedPath;
+ if ((path[path.length - 1] === "/") || (segments[segments.length - 1] === ".") || (segments[segments.length - 1] === ".."))
+ normalizedPath = normalizedPath + "/";
+
+ return normalizedPath;
+}
+
/**
* This function behavior depends on the "debug_devtools" flag value.
* - In debug mode it loads scripts synchronously via xhr request.
@@ -62,6 +95,8 @@ function loadResource(url)
function importScript(scriptName)
{
var sourceURL = self._importScriptPathPrefix + scriptName;
+ var schemaIndex = sourceURL.indexOf("://") + 3;
+ sourceURL = sourceURL.substring(0, schemaIndex) + normalizePath(sourceURL.substring(schemaIndex));
if (_importedScripts[sourceURL])
return;
_importedScripts[sourceURL] = true;
« no previous file with comments | « no previous file | Source/devtools/front_end/common/ParsedURL.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698