| OLD | NEW |
| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 * @return {string} | 252 * @return {string} |
| 253 */ | 253 */ |
| 254 lastPathComponentWithFragment: function() | 254 lastPathComponentWithFragment: function() |
| 255 { | 255 { |
| 256 return this.lastPathComponent + (this.fragment ? "#" + this.fragment : ""
); | 256 return this.lastPathComponent + (this.fragment ? "#" + this.fragment : ""
); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * @param {string} string | 261 * @param {string} string |
| 262 * @return {?{url: string, lineNumber: (number|undefined), columnNumber: (number
|undefined)}} | 262 * @return {!{url: string, lineNumber: (number|undefined), columnNumber: (number
|undefined)}} |
| 263 */ | 263 */ |
| 264 WebInspector.ParsedURL.splitLineAndColumn = function(string) | 264 WebInspector.ParsedURL.splitLineAndColumn = function(string) |
| 265 { | 265 { |
| 266 var lineColumnRegEx = /:(\d+)(:(\d+))?$/; | 266 var lineColumnRegEx = /(?::(\d+))?(?::(\d+))?$/; |
| 267 var lineColumnMatch = lineColumnRegEx.exec(string); | 267 var lineColumnMatch = lineColumnRegEx.exec(string); |
| 268 var lineNumber; | 268 var lineNumber; |
| 269 var columnNumber; | 269 var columnNumber; |
| 270 if (!lineColumnMatch) | 270 console.assert(lineColumnMatch); |
| 271 return null; | |
| 272 | 271 |
| 273 lineNumber = parseInt(lineColumnMatch[1], 10); | 272 if (typeof(lineColumnMatch[1]) === "string") { |
| 274 // Immediately convert line and column to 0-based numbers. | 273 lineNumber = parseInt(lineColumnMatch[1], 10); |
| 275 lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1; | 274 // Immediately convert line and column to 0-based numbers. |
| 276 if (typeof(lineColumnMatch[3]) === "string") { | 275 lineNumber = isNaN(lineNumber) ? undefined : lineNumber - 1; |
| 277 columnNumber = parseInt(lineColumnMatch[3], 10); | 276 } |
| 277 if (typeof(lineColumnMatch[2]) === "string") { |
| 278 columnNumber = parseInt(lineColumnMatch[2], 10); |
| 278 columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1; | 279 columnNumber = isNaN(columnNumber) ? undefined : columnNumber - 1; |
| 279 } | 280 } |
| 280 | 281 |
| 281 return { url: string.substring(0, string.length - lineColumnMatch[0].length)
, lineNumber: lineNumber, columnNumber: columnNumber}; | 282 return {url: string.substring(0, string.length - lineColumnMatch[0].length),
lineNumber: lineNumber, columnNumber: columnNumber}; |
| 282 } | 283 } |
| 283 | 284 |
| 284 /** | 285 /** |
| 285 * @return {?WebInspector.ParsedURL} | 286 * @return {?WebInspector.ParsedURL} |
| 286 */ | 287 */ |
| 287 String.prototype.asParsedURL = function() | 288 String.prototype.asParsedURL = function() |
| 288 { | 289 { |
| 289 var parsedURL = new WebInspector.ParsedURL(this.toString()); | 290 var parsedURL = new WebInspector.ParsedURL(this.toString()); |
| 290 if (parsedURL.isValid) | 291 if (parsedURL.isValid) |
| 291 return parsedURL; | 292 return parsedURL; |
| 292 return null; | 293 return null; |
| 293 } | 294 } |
| OLD | NEW |