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

Unified Diff: Source/devtools/front_end/common/ParsedURL.js

Issue 674513002: DevTools: linkify relative links in console.log(new Error().stack) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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: Source/devtools/front_end/common/ParsedURL.js
diff --git a/Source/devtools/front_end/common/ParsedURL.js b/Source/devtools/front_end/common/ParsedURL.js
index 0f093e52ce94cf78a7b4a38f45d94b610f7db05a..f0568cdea6f0680f07e7f071f5e9125ec5f6cf81 100644
--- a/Source/devtools/front_end/common/ParsedURL.js
+++ b/Source/devtools/front_end/common/ParsedURL.js
@@ -240,6 +240,30 @@ WebInspector.ParsedURL.prototype = {
}
/**
+ * @param {string} string
+ * @return {?{url: string, lineNumber: (number|undefined), columnNumber: (number|undefined)}}
+ */
+WebInspector.ParsedURL.splitLineAndColumn = function(string)
+{
+ var lineColumnRegEx = /:(\d+)(:(\d+))?$/;
+ var lineColumnMatch = lineColumnRegEx.exec(string);
+ var lineNumber;
+ var columnNumber;
+ if (!lineColumnMatch)
+ return null;
+
+ lineNumber = parseInt(lineColumnMatch[1], 10);
+ // Immediately convert line and column to 0-based numbers.
+ lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1;
+ if (typeof(lineColumnMatch[3]) === "string") {
+ columnNumber = parseInt(lineColumnMatch[3], 10);
+ columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1;
+ }
+
+ return { url: string.substring(0, string.length - lineColumnMatch[0].length), lineNumber: lineNumber, columnNumber: columnNumber};
+}
+
+/**
* @return {?WebInspector.ParsedURL}
*/
String.prototype.asParsedURL = function()

Powered by Google App Engine
This is Rietveld 408576698