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

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: Address aandrey comments 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 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]+) )?(?:(\/[^\s<>#]*)(?:#(.*))?)?$/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 170 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