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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 /** 233 /**
234 * @return {boolean} 234 * @return {boolean}
235 */ 235 */
236 isDataURL: function() 236 isDataURL: function()
237 { 237 {
238 return this.scheme === "data"; 238 return this.scheme === "data";
239 } 239 }
240 } 240 }
241 241
242 /** 242 /**
243 * @param {string} string
244 * @return {?{url: string, lineNumber: (number|undefined), columnNumber: (number |undefined)}}
245 */
246 WebInspector.ParsedURL.splitLineAndColumn = function(string)
247 {
248 var lineColumnRegEx = /:(\d+)(:(\d+))?$/;
249 var lineColumnMatch = lineColumnRegEx.exec(string);
250 var lineNumber;
251 var columnNumber;
252 if (!lineColumnMatch)
253 return null;
254
255 lineNumber = parseInt(lineColumnMatch[1], 10);
256 // Immediately convert line and column to 0-based numbers.
257 lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1;
258 if (typeof(lineColumnMatch[3]) === "string") {
259 columnNumber = parseInt(lineColumnMatch[3], 10);
260 columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1;
261 }
262
263 return { url: string.substring(0, string.length - lineColumnMatch[0].length) , lineNumber: lineNumber, columnNumber: columnNumber};
264 }
265
266 /**
243 * @return {?WebInspector.ParsedURL} 267 * @return {?WebInspector.ParsedURL}
244 */ 268 */
245 String.prototype.asParsedURL = function() 269 String.prototype.asParsedURL = function()
246 { 270 {
247 var parsedURL = new WebInspector.ParsedURL(this.toString()); 271 var parsedURL = new WebInspector.ParsedURL(this.toString());
248 if (parsedURL.isValid) 272 if (parsedURL.isValid)
249 return parsedURL; 273 return parsedURL;
250 return null; 274 return null;
251 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698