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

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: 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 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 this.fragment = ""; 42 this.fragment = "";
43 this.folderPathComponents = ""; 43 this.folderPathComponents = "";
44 this.lastPathComponent = ""; 44 this.lastPathComponent = "";
45 45
46 // RegExp groups: 46 // RegExp groups:
47 // 1 - scheme (using the RFC3986 grammar) 47 // 1 - scheme (using the RFC3986 grammar)
48 // 2 - hostname 48 // 2 - hostname
49 // 3 - ?port 49 // 3 - ?port
50 // 4 - ?path 50 // 4 - ?path
51 // 5 - ?fragment 51 // 5 - ?fragment
52 var match = url.match(/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^\/:]*)(?::([\d]+))? (?:(\/[^#]*)(?:#(.*))?)?$/i); 52 var match = url.match(/^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^\s\/:]*)(?::([\d]+) )?(?:(\/[^#]*)(?:#(.*))?)?$/i);
53 if (match) { 53 if (match) {
54 this.isValid = true; 54 this.isValid = true;
55 this.scheme = match[1].toLowerCase(); 55 this.scheme = match[1].toLowerCase();
56 this.host = match[2]; 56 this.host = match[2];
57 this.port = match[3]; 57 this.port = match[3];
58 this.path = match[4] || "/"; 58 this.path = match[4] || "/";
59 this.fragment = match[5]; 59 this.fragment = match[5];
60 } else { 60 } else {
61 if (this.url.startsWith("data:")) { 61 if (this.url.startsWith("data:")) {
62 this.scheme = "data"; 62 this.scheme = "data";
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 /** 243 /**
244 * @return {boolean} 244 * @return {boolean}
245 */ 245 */
246 isDataURL: function() 246 isDataURL: function()
247 { 247 {
248 return this.scheme === "data"; 248 return this.scheme === "data";
249 } 249 }
250 } 250 }
251 251
252 /** 252 /**
253 * @param {string} string
254 * @return {?{url: string, lineNumber: (number|undefined), columnNumber: (number |undefined)}}
255 */
256 WebInspector.ParsedURL.splitLineAndColumn = function(string)
257 {
258 var lineColumnRegEx = /:(\d+)(:(\d+))?$/;
259 var lineColumnMatch = lineColumnRegEx.exec(string);
260 var lineNumber;
261 var columnNumber;
262 if (!lineColumnMatch)
263 return null;
264
265 lineNumber = parseInt(lineColumnMatch[1], 10);
266 // Immediately convert line and column to 0-based numbers.
267 lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1;
268 if (typeof(lineColumnMatch[3]) === "string") {
269 columnNumber = parseInt(lineColumnMatch[3], 10);
270 columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1;
271 }
272
273 return { url: string.substring(0, string.length - lineColumnMatch[0].length) , lineNumber: lineNumber, columnNumber: columnNumber};
274 }
275
276 /**
253 * @return {?WebInspector.ParsedURL} 277 * @return {?WebInspector.ParsedURL}
254 */ 278 */
255 String.prototype.asParsedURL = function() 279 String.prototype.asParsedURL = function()
256 { 280 {
257 var parsedURL = new WebInspector.ParsedURL(this.toString()); 281 var parsedURL = new WebInspector.ParsedURL(this.toString());
258 if (parsedURL.isValid) 282 if (parsedURL.isValid)
259 return parsedURL; 283 return parsedURL;
260 return null; 284 return null;
261 } 285 }
OLDNEW
« 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