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

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: Fix tests Created 6 years, 1 month 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 7976b5cb3e66bca289e3d935e8c78be95bb30766..338dbd72fbecf879cdb6a07d28ba914f14b06887 100644
--- a/Source/devtools/front_end/common/ParsedURL.js
+++ b/Source/devtools/front_end/common/ParsedURL.js
@@ -49,7 +49,7 @@ WebInspector.ParsedURL = function(url)
// 3 - ?port
// 4 - ?path
// 5 - ?fragment
- var match = url.match(/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
+ var match = url.match(/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^\s\/:]*)(?::([\d]+))?(?:(\/[^#]*)(?:#(.*))?)?$/i);
if (match) {
this.isValid = true;
this.scheme = match[1].toLowerCase();
@@ -250,6 +250,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()
« no previous file with comments | « Source/devtools/front_end/bindings/ResourceUtils.js ('k') | Source/devtools/front_end/console/ConsoleViewMessage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698