| 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 { | 304 { |
| 305 var commonPathSuffixLength = 0; | 305 var commonPathSuffixLength = 0; |
| 306 for (var i = 0; i < filePath.length; ++i) { | 306 for (var i = 0; i < filePath.length; ++i) { |
| 307 var filePathCharacter = filePath[filePath.length - 1 - i]; | 307 var filePathCharacter = filePath[filePath.length - 1 - i]; |
| 308 var urlCharacter = url[url.length - 1 - i]; | 308 var urlCharacter = url[url.length - 1 - i]; |
| 309 if (filePathCharacter !== urlCharacter) | 309 if (filePathCharacter !== urlCharacter) |
| 310 break; | 310 break; |
| 311 if (filePathCharacter === "/") | 311 if (filePathCharacter === "/") |
| 312 commonPathSuffixLength = i; | 312 commonPathSuffixLength = i; |
| 313 } | 313 } |
| 314 var pathPrefix = filePath.substring(fileSystemPath.length, filePath.leng
th - commonPathSuffixLength); | 314 var from = fileSystemPath.length; |
| 315 var to = filePath.length - commonPathSuffixLength; |
| 316 var pathPrefix = filePath.substring(from, to); |
| 315 var urlPrefix = url.substr(0, url.length - commonPathSuffixLength); | 317 var urlPrefix = url.substr(0, url.length - commonPathSuffixLength); |
| 316 this.addFileMapping(fileSystemPath, urlPrefix, pathPrefix); | 318 if (to >= from) |
| 319 this.addFileMapping(fileSystemPath, urlPrefix, pathPrefix); |
| 320 else |
| 321 this.addFileMapping(fileSystemPath, urlPrefix + pathPrefix, "/"); |
| 317 }, | 322 }, |
| 318 | 323 |
| 319 resetForTesting: function() | 324 resetForTesting: function() |
| 320 { | 325 { |
| 321 this._fileSystemMappings = {}; | 326 this._fileSystemMappings = {}; |
| 322 }, | 327 }, |
| 323 | 328 |
| 324 __proto__: WebInspector.Object.prototype | 329 __proto__: WebInspector.Object.prototype |
| 325 } | 330 } |
| 326 | 331 |
| 327 /** | 332 /** |
| 328 * @constructor | 333 * @constructor |
| 329 * @param {string} fileSystemPath | 334 * @param {string} fileSystemPath |
| 330 * @param {string} urlPrefix | 335 * @param {string} urlPrefix |
| 331 * @param {string} pathPrefix | 336 * @param {string} pathPrefix |
| 332 * @param {boolean} configurable | 337 * @param {boolean} configurable |
| 333 */ | 338 */ |
| 334 WebInspector.FileSystemMapping.Entry = function(fileSystemPath, urlPrefix, pathP
refix, configurable) | 339 WebInspector.FileSystemMapping.Entry = function(fileSystemPath, urlPrefix, pathP
refix, configurable) |
| 335 { | 340 { |
| 336 this.fileSystemPath = fileSystemPath; | 341 this.fileSystemPath = fileSystemPath; |
| 337 this.urlPrefix = urlPrefix; | 342 this.urlPrefix = urlPrefix; |
| 338 this.pathPrefix = pathPrefix; | 343 this.pathPrefix = pathPrefix; |
| 339 this.configurable = configurable; | 344 this.configurable = configurable; |
| 340 } | 345 } |
| 341 | 346 |
| 342 /** | 347 /** |
| 343 * @type {!WebInspector.FileSystemMapping} | 348 * @type {!WebInspector.FileSystemMapping} |
| 344 */ | 349 */ |
| 345 WebInspector.fileSystemMapping; | 350 WebInspector.fileSystemMapping; |
| OLD | NEW |