[Pkg-javascript-commits] [node-source-map] 01/05: New upstream version 0.6.1+dfsg

Julien Puydt julien.puydt at laposte.net
Sun Oct 1 19:32:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-source-map.

commit d11c8a913f3b52bbbe1bf59133bedd4c0b6a33d2
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sun Oct 1 21:27:53 2017 +0200

    New upstream version 0.6.1+dfsg
---
 dist/source-map.debug.js               |  78 +++++++++++++++----------
 dist/source-map.js                     |  76 ++++++++++++++----------
 dist/source-map.min.js                 |   2 +-
 dist/source-map.min.js.map             |   2 +-
 dist/test/test_api.js                  |  78 +++++++++++++++----------
 dist/test/test_dog_fooding.js          |  78 +++++++++++++++----------
 dist/test/test_source_map_consumer.js  | 103 ++++++++++++++++++++++-----------
 dist/test/test_source_map_generator.js |  78 +++++++++++++++----------
 dist/test/test_source_node.js          |  78 +++++++++++++++----------
 lib/source-map-consumer.js             |  76 ++++++++++++++----------
 package.json                           |   2 +-
 test/test-source-map-consumer.js       |  25 +++++++-
 12 files changed, 423 insertions(+), 253 deletions(-)

diff --git a/dist/source-map.debug.js b/dist/source-map.debug.js
index 4308614..aad0620 100644
--- a/dist/source-map.debug.js
+++ b/dist/source-map.debug.js
@@ -1448,8 +1448,8 @@ return /******/ (function(modules) { // webpackBootstrap
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 	
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 	
 	/**
@@ -1619,13 +1619,10 @@ return /******/ (function(modules) { // webpackBootstrap
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 	
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 	
 	    var mappings = [];
 	
@@ -1763,6 +1760,10 @@ return /******/ (function(modules) { // webpackBootstrap
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 	
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+	
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -1774,6 +1775,32 @@ return /******/ (function(modules) { // webpackBootstrap
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 	
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+	
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+	
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+	
+	  return -1;
+	};
+	
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -1793,6 +1820,9 @@ return /******/ (function(modules) { // webpackBootstrap
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 	
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -1839,9 +1869,7 @@ return /******/ (function(modules) { // webpackBootstrap
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 	
@@ -2111,25 +2139,16 @@ return /******/ (function(modules) { // webpackBootstrap
 	      return null;
 	    }
 	
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+	
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 	
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-	
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-	
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -2187,17 +2206,14 @@ return /******/ (function(modules) { // webpackBootstrap
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 	
 	    var needle = {
 	      source: source,
@@ -2474,7 +2490,7 @@ return /******/ (function(modules) { // webpackBootstrap
 	
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
@@ -3215,4 +3231,4 @@ return /******/ (function(modules) { // webpackBootstrap
 /******/ ])
 });
 ;
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCA3MmMxZTZhODQ5ZWNiOTIwODM1MCIsIndlYnBhY2s6Ly8vLi9zb3VyY2UtbWFwLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWdlbmVyYXRvci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LXZscS5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJw [...]
\ No newline at end of file
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCAxNjI0YzcyOTliODg3ZjdiZGY2NCIsIndlYnBhY2s6Ly8vLi9zb3VyY2UtbWFwLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWdlbmVyYXRvci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LXZscS5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJw [...]
\ No newline at end of file
diff --git a/dist/source-map.js b/dist/source-map.js
index 6022d2a..b4eb087 100644
--- a/dist/source-map.js
+++ b/dist/source-map.js
@@ -1448,8 +1448,8 @@ return /******/ (function(modules) { // webpackBootstrap
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 
 	/**
@@ -1619,13 +1619,10 @@ return /******/ (function(modules) { // webpackBootstrap
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 
 	    var mappings = [];
 
@@ -1763,6 +1760,10 @@ return /******/ (function(modules) { // webpackBootstrap
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -1774,6 +1775,32 @@ return /******/ (function(modules) { // webpackBootstrap
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+
+	  return -1;
+	};
+
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -1793,6 +1820,9 @@ return /******/ (function(modules) { // webpackBootstrap
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -1839,9 +1869,7 @@ return /******/ (function(modules) { // webpackBootstrap
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 
@@ -2111,25 +2139,16 @@ return /******/ (function(modules) { // webpackBootstrap
 	      return null;
 	    }
 
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -2187,17 +2206,14 @@ return /******/ (function(modules) { // webpackBootstrap
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 
 	    var needle = {
 	      source: source,
@@ -2474,7 +2490,7 @@ return /******/ (function(modules) { // webpackBootstrap
 
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
diff --git a/dist/source-map.min.js b/dist/source-map.min.js
index 2150560..c7c72da 100644
--- a/dist/source-map.min.js
+++ b/dist/source-map.min.js
@@ -1,2 +1,2 @@
-!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sourceMap=n():e.sourceMap=n()}(this,function(){return function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){n.SourceMapGenerator=r(1).SourceMapGenerator,n.SourceMa [...]
+!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sourceMap=n():e.sourceMap=n()}(this,function(){return function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){n.SourceMapGenerator=r(1).SourceMapGenerator,n.SourceMa [...]
 //# sourceMappingURL=source-map.min.js.map
\ No newline at end of file
diff --git a/dist/source-map.min.js.map b/dist/source-map.min.js.map
index 57477f7..d2cc86e 100644
--- a/dist/source-map.min.js.map
+++ b/dist/source-map.min.js.map
@@ -1 +1 @@
-{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///source-map.min.js","webpack:///webpack/bootstrap 3093113f7ca9ad8efffd","webpack:///./source-map.js","webpack:///./lib/source-map-generator.js","webpack:///./lib/base64-vlq.js","webpack:///./lib/base64.js","webpack:///./lib/util.js","webpack:///./lib/array-set.js","webpack:///./lib/mapping-list.js","webpack:///./lib/source-map-consumer.js","webpack:///./lib/binary-search.js","webpack:///./lib/quick-sort.js" [...]
\ No newline at end of file
+{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///source-map.min.js","webpack:///webpack/bootstrap 0fd5815da764db5fb9fe","webpack:///./source-map.js","webpack:///./lib/source-map-generator.js","webpack:///./lib/base64-vlq.js","webpack:///./lib/base64.js","webpack:///./lib/util.js","webpack:///./lib/array-set.js","webpack:///./lib/mapping-list.js","webpack:///./lib/source-map-consumer.js","webpack:///./lib/binary-search.js","webpack:///./lib/quick-sort.js" [...]
\ No newline at end of file
diff --git a/dist/test/test_api.js b/dist/test/test_api.js
index 68bda9b..dbffa4b 100644
--- a/dist/test/test_api.js
+++ b/dist/test/test_api.js
@@ -1468,8 +1468,8 @@ var SOURCE_MAP_TEST_MODULE =
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 	
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 	
 	/**
@@ -1639,13 +1639,10 @@ var SOURCE_MAP_TEST_MODULE =
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 	
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 	
 	    var mappings = [];
 	
@@ -1783,6 +1780,10 @@ var SOURCE_MAP_TEST_MODULE =
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 	
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+	
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -1794,6 +1795,32 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 	
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+	
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+	
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+	
+	  return -1;
+	};
+	
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -1813,6 +1840,9 @@ var SOURCE_MAP_TEST_MODULE =
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 	
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -1859,9 +1889,7 @@ var SOURCE_MAP_TEST_MODULE =
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 	
@@ -2131,25 +2159,16 @@ var SOURCE_MAP_TEST_MODULE =
 	      return null;
 	    }
 	
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+	
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 	
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-	
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-	
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -2207,17 +2226,14 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 	
 	    var needle = {
 	      source: source,
@@ -2494,7 +2510,7 @@ var SOURCE_MAP_TEST_MODULE =
 	
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
@@ -3233,4 +3249,4 @@ var SOURCE_MAP_TEST_MODULE =
 
 /***/ })
 /******/ ]);
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgM2VmZjI4Y2FkMDE3ODEyMWMzM2QiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LWFwaS5qcyIsIndlYnBhY2s6Ly8vLi9zb3VyY2UtbWFwLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWdlbmVyYXRvci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LXZscS5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL21h [...]
\ No newline at end of file
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgZmQyYzI3NDJhYTQ3MDI2YzM5YjMiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LWFwaS5qcyIsIndlYnBhY2s6Ly8vLi9zb3VyY2UtbWFwLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWdlbmVyYXRvci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LXZscS5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL21h [...]
\ No newline at end of file
diff --git a/dist/test/test_dog_fooding.js b/dist/test/test_dog_fooding.js
index b0c7af0..210dc09 100644
--- a/dist/test/test_dog_fooding.js
+++ b/dist/test/test_dog_fooding.js
@@ -1031,8 +1031,8 @@ var SOURCE_MAP_TEST_MODULE =
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 	
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 	
 	/**
@@ -1202,13 +1202,10 @@ var SOURCE_MAP_TEST_MODULE =
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 	
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 	
 	    var mappings = [];
 	
@@ -1346,6 +1343,10 @@ var SOURCE_MAP_TEST_MODULE =
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 	
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+	
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -1357,6 +1358,32 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 	
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+	
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+	
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+	
+	  return -1;
+	};
+	
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -1376,6 +1403,9 @@ var SOURCE_MAP_TEST_MODULE =
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 	
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -1422,9 +1452,7 @@ var SOURCE_MAP_TEST_MODULE =
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 	
@@ -1694,25 +1722,16 @@ var SOURCE_MAP_TEST_MODULE =
 	      return null;
 	    }
 	
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+	
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 	
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-	
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-	
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -1770,17 +1789,14 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 	
 	    var needle = {
 	      source: source,
@@ -2057,7 +2073,7 @@ var SOURCE_MAP_TEST_MODULE =
 	
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
@@ -3239,4 +3255,4 @@ var SOURCE_MAP_TEST_MODULE =
 
 /***/ })
 /******/ ]);
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgNDYwYzc5Yzc3MDg2YWU2MzYwNWYiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LWRvZy1mb29kaW5nLmpzIiwid2VicGFjazovLy8uL3Rlc3QvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvc291cmNlLW1hcC1jb25zdW1lci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmluYXJ5LXNlYXJjaC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYXJyYXktc2V0LmpzIiwid2VicGFjazovLy8uL2xpYi9iYXNlNjQtdmxxLmpzIiwid2VicGFj [...]
\ No newline at end of file
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgMzg3OGJhYzdhNTYxNTBjMmFhYmIiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LWRvZy1mb29kaW5nLmpzIiwid2VicGFjazovLy8uL3Rlc3QvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvc291cmNlLW1hcC1jb25zdW1lci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmluYXJ5LXNlYXJjaC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYXJyYXktc2V0LmpzIiwid2VicGFjazovLy8uL2xpYi9iYXNlNjQtdmxxLmpzIiwid2VicGFj [...]
\ No newline at end of file
diff --git a/dist/test/test_source_map_consumer.js b/dist/test/test_source_map_consumer.js
index 81efae5..72bf3b6 100644
--- a/dist/test/test_source_map_consumer.js
+++ b/dist/test/test_source_map_consumer.js
@@ -554,7 +554,7 @@ var SOURCE_MAP_TEST_MODULE =
 	    generated: { line: 6, column: 6 },
 	    source: 'bang.coffee'
 	  });
-	  map = new SourceMapConsumer(map.toString());
+	  map = new SourceMapConsumer(map.toString(), 'http://example.com/');
 	
 	  // Should handle without sourceRoot.
 	  var pos = map.generatedPositionFor({
@@ -575,6 +575,16 @@ var SOURCE_MAP_TEST_MODULE =
 	
 	  assert.equal(pos.line, 2);
 	  assert.equal(pos.column, 2);
+	
+	  // Should handle absolute case.
+	  var pos = map.generatedPositionFor({
+	    line: 1,
+	    column: 1,
+	    source: 'http://example.com/foo/bar/bang.coffee'
+	  });
+	
+	  assert.equal(pos.line, 2);
+	  assert.equal(pos.column, 2);
 	};
 	
 	exports['test sourceRoot + generatedPositionFor for path above the root'] = function (assert) {
@@ -629,7 +639,7 @@ var SOURCE_MAP_TEST_MODULE =
 	    generated: { line: 4, column: 2 },
 	    source: 'bar.coffee'
 	  });
-	  map = new SourceMapConsumer(map.toString());
+	  map = new SourceMapConsumer(map.toString(), 'http://example.com/');
 	
 	  var mappings = map.allGeneratedPositionsFor({
 	    line: 2,
@@ -641,6 +651,17 @@ var SOURCE_MAP_TEST_MODULE =
 	  assert.equal(mappings[0].column, 2);
 	  assert.equal(mappings[1].line, 3);
 	  assert.equal(mappings[1].column, 3);
+	
+	  mappings = map.allGeneratedPositionsFor({
+	    line: 2,
+	    source: 'http://example.com/bar.coffee'
+	  });
+	
+	  assert.equal(mappings.length, 2);
+	  assert.equal(mappings[0].line, 3);
+	  assert.equal(mappings[0].column, 2);
+	  assert.equal(mappings[1].line, 3);
+	  assert.equal(mappings[1].column, 3);
 	};
 	
 	exports['test allGeneratedPositionsFor for line fuzzy'] = function (assert) {
@@ -2159,8 +2180,8 @@ var SOURCE_MAP_TEST_MODULE =
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 	
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 	
 	/**
@@ -2330,13 +2351,10 @@ var SOURCE_MAP_TEST_MODULE =
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 	
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 	
 	    var mappings = [];
 	
@@ -2474,6 +2492,10 @@ var SOURCE_MAP_TEST_MODULE =
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 	
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+	
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -2485,6 +2507,32 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 	
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+	
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+	
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+	
+	  return -1;
+	};
+	
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -2504,6 +2552,9 @@ var SOURCE_MAP_TEST_MODULE =
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 	
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -2550,9 +2601,7 @@ var SOURCE_MAP_TEST_MODULE =
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 	
@@ -2822,25 +2871,16 @@ var SOURCE_MAP_TEST_MODULE =
 	      return null;
 	    }
 	
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+	
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 	
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-	
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-	
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -2898,17 +2938,14 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 	
 	    var needle = {
 	      source: source,
@@ -3185,7 +3222,7 @@ var SOURCE_MAP_TEST_MODULE =
 	
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
@@ -4367,4 +4404,4 @@ var SOURCE_MAP_TEST_MODULE =
 
 /***/ })
 /******/ ]);
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgNTg4ZmJiMWFlNGU1MDljNjhlMTkiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LXNvdXJjZS1tYXAtY29uc3VtZXIuanMiLCJ3ZWJwYWNrOi8vLy4vdGVzdC91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWNvbnN1bWVyLmpzIiwid2VicGFjazovLy8uL2xpYi9iaW5hcnktc2VhcmNoLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL2Jhc2U2NC12bHEuanMi [...]
\ No newline at end of file
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgZjlkMDZlY2IxNmIzOTZhNzNlNGUiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LXNvdXJjZS1tYXAtY29uc3VtZXIuanMiLCJ3ZWJwYWNrOi8vLy4vdGVzdC91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWNvbnN1bWVyLmpzIiwid2VicGFjazovLy8uL2xpYi9iaW5hcnktc2VhcmNoLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL2Jhc2U2NC12bHEuanMi [...]
\ No newline at end of file
diff --git a/dist/test/test_source_map_generator.js b/dist/test/test_source_map_generator.js
index a914ae9..2460d66 100644
--- a/dist/test/test_source_map_generator.js
+++ b/dist/test/test_source_map_generator.js
@@ -2218,8 +2218,8 @@ var SOURCE_MAP_TEST_MODULE =
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 	
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 	
 	/**
@@ -2389,13 +2389,10 @@ var SOURCE_MAP_TEST_MODULE =
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 	
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 	
 	    var mappings = [];
 	
@@ -2533,6 +2530,10 @@ var SOURCE_MAP_TEST_MODULE =
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 	
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+	
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -2544,6 +2545,32 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 	
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+	
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+	
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+	
+	  return -1;
+	};
+	
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -2563,6 +2590,9 @@ var SOURCE_MAP_TEST_MODULE =
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 	
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -2609,9 +2639,7 @@ var SOURCE_MAP_TEST_MODULE =
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 	
@@ -2881,25 +2909,16 @@ var SOURCE_MAP_TEST_MODULE =
 	      return null;
 	    }
 	
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+	
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 	
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-	
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-	
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -2957,17 +2976,14 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 	
 	    var needle = {
 	      source: source,
@@ -3244,7 +3260,7 @@ var SOURCE_MAP_TEST_MODULE =
 	
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
@@ -4336,4 +4352,4 @@ var SOURCE_MAP_TEST_MODULE =
 
 /***/ })
 /******/ ]);
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgZDI1OWQ2YzJjMjNmNDk1MDI2NGQiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LXNvdXJjZS1tYXAtZ2VuZXJhdG9yLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWdlbmVyYXRvci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LXZscS5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL21hcHBpbmctbGlzdC5q [...]
\ No newline at end of file
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgYzQ3ODE4Y2EyYjFhYzU3ZmYwMTgiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LXNvdXJjZS1tYXAtZ2VuZXJhdG9yLmpzIiwid2VicGFjazovLy8uL2xpYi9zb3VyY2UtbWFwLWdlbmVyYXRvci5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LXZscS5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYmFzZTY0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIiwid2VicGFjazovLy8uL2xpYi9hcnJheS1zZXQuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL21hcHBpbmctbGlzdC5q [...]
\ No newline at end of file
diff --git a/dist/test/test_source_node.js b/dist/test/test_source_node.js
index 86b2804..f9f99b7 100644
--- a/dist/test/test_source_node.js
+++ b/dist/test/test_source_node.js
@@ -2400,8 +2400,8 @@ var SOURCE_MAP_TEST_MODULE =
 	    : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 	}
 	
-	SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+	SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+	  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 	}
 	
 	/**
@@ -2571,13 +2571,10 @@ var SOURCE_MAP_TEST_MODULE =
 	      originalColumn: util.getArg(aArgs, 'column', 0)
 	    };
 	
-	    if (this.sourceRoot != null) {
-	      needle.source = util.relative(this.sourceRoot, needle.source);
-	    }
-	    if (!this._sources.has(needle.source)) {
+	    needle.source = this._findSourceIndex(needle.source);
+	    if (needle.source < 0) {
 	      return [];
 	    }
-	    needle.source = this._sources.indexOf(needle.source);
 	
 	    var mappings = [];
 	
@@ -2715,6 +2712,10 @@ var SOURCE_MAP_TEST_MODULE =
 	  this._names = ArraySet.fromArray(names.map(String), true);
 	  this._sources = ArraySet.fromArray(sources, true);
 	
+	  this._absoluteSources = this._sources.toArray().map(function (s) {
+	    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+	  });
+	
 	  this.sourceRoot = sourceRoot;
 	  this.sourcesContent = sourcesContent;
 	  this._mappings = mappings;
@@ -2726,6 +2727,32 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 	
 	/**
+	 * Utility function to find the index of a source.  Returns -1 if not
+	 * found.
+	 */
+	BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+	  var relativeSource = aSource;
+	  if (this.sourceRoot != null) {
+	    relativeSource = util.relative(this.sourceRoot, relativeSource);
+	  }
+	
+	  if (this._sources.has(relativeSource)) {
+	    return this._sources.indexOf(relativeSource);
+	  }
+	
+	  // Maybe aSource is an absolute URL as returned by |sources|.  In
+	  // this case we can't simply undo the transform.
+	  var i;
+	  for (i = 0; i < this._absoluteSources.length; ++i) {
+	    if (this._absoluteSources[i] == aSource) {
+	      return i;
+	    }
+	  }
+	
+	  return -1;
+	};
+	
+	/**
 	 * Create a BasicSourceMapConsumer from a SourceMapGenerator.
 	 *
 	 * @param SourceMapGenerator aSourceMap
@@ -2745,6 +2772,9 @@ var SOURCE_MAP_TEST_MODULE =
 	                                                            smc.sourceRoot);
 	    smc.file = aSourceMap._file;
 	    smc._sourceMapURL = aSourceMapURL;
+	    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+	      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+	    });
 	
 	    // Because we are modifying the entries (by converting string sources and
 	    // names to indices into the sources and names ArraySets), we have to make
@@ -2791,9 +2821,7 @@ var SOURCE_MAP_TEST_MODULE =
 	 */
 	Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
 	  get: function () {
-	    return this._sources.toArray().map(function (s) {
-	      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-	    }, this);
+	    return this._absoluteSources.slice();
 	  }
 	});
 	
@@ -3063,25 +3091,16 @@ var SOURCE_MAP_TEST_MODULE =
 	      return null;
 	    }
 	
+	    var index = this._findSourceIndex(aSource);
+	    if (index >= 0) {
+	      return this.sourcesContent[index];
+	    }
+	
 	    var relativeSource = aSource;
 	    if (this.sourceRoot != null) {
 	      relativeSource = util.relative(this.sourceRoot, relativeSource);
 	    }
 	
-	    if (this._sources.has(relativeSource)) {
-	      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-	    }
-	
-	    // Maybe aSource is an absolute URL as returned by |sources|.  In
-	    // this case we can't simply undo the transform.
-	    var sourceArray = this.sources;
-	    var i;
-	    for (i = 0; i < sourceArray.length; ++i) {
-	      if (sourceArray[i] == aSource) {
-	        return this.sourcesContent[i];
-	      }
-	    }
-	
 	    var url;
 	    if (this.sourceRoot != null
 	        && (url = util.urlParse(this.sourceRoot))) {
@@ -3139,17 +3158,14 @@ var SOURCE_MAP_TEST_MODULE =
 	BasicSourceMapConsumer.prototype.generatedPositionFor =
 	  function SourceMapConsumer_generatedPositionFor(aArgs) {
 	    var source = util.getArg(aArgs, 'source');
-	    if (this.sourceRoot != null) {
-	      source = util.relative(this.sourceRoot, source);
-	    }
-	    if (!this._sources.has(source)) {
+	    source = this._findSourceIndex(source);
+	    if (source < 0) {
 	      return {
 	        line: null,
 	        column: null,
 	        lastColumn: null
 	      };
 	    }
-	    source = this._sources.indexOf(source);
 	
 	    var needle = {
 	      source: source,
@@ -3426,7 +3442,7 @@ var SOURCE_MAP_TEST_MODULE =
 	
 	      // Only consider this section if the requested source is in the list of
 	      // sources of the consumer.
-	      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+	      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
 	        continue;
 	      }
 	      var generatedPosition = section.consumer.generatedPositionFor(aArgs);
@@ -4165,4 +4181,4 @@ var SOURCE_MAP_TEST_MODULE =
 
 /***/ })
 /******/ ]);
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgMDNmZDU3NzA3ZTNhYjIwNDQ0ZGMiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LXNvdXJjZS1ub2RlLmpzIiwid2VicGFjazovLy8uL3Rlc3QvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvc291cmNlLW1hcC1nZW5lcmF0b3IuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL2Jhc2U2NC12bHEuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL2Jhc2U2NC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYXJyYXktc2V0LmpzIiwid2VicGFjazovLy8u [...]
\ No newline at end of file
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgMjhjY2VhMDczNmY3MTBkMjViODciLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LXNvdXJjZS1ub2RlLmpzIiwid2VicGFjazovLy8uL3Rlc3QvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvdXRpbC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvc291cmNlLW1hcC1nZW5lcmF0b3IuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL2Jhc2U2NC12bHEuanMiLCJ3ZWJwYWNrOi8vLy4vbGliL2Jhc2U2NC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYXJyYXktc2V0LmpzIiwid2VicGFjazovLy8u [...]
\ No newline at end of file
diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js
index 37b5357..7b99d1d 100644
--- a/lib/source-map-consumer.js
+++ b/lib/source-map-consumer.js
@@ -22,8 +22,8 @@ function SourceMapConsumer(aSourceMap, aSourceMapURL) {
     : new BasicSourceMapConsumer(sourceMap, aSourceMapURL);
 }
 
-SourceMapConsumer.fromSourceMap = function(aSourceMap) {
-  return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
+SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) {
+  return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL);
 }
 
 /**
@@ -193,13 +193,10 @@ SourceMapConsumer.prototype.allGeneratedPositionsFor =
       originalColumn: util.getArg(aArgs, 'column', 0)
     };
 
-    if (this.sourceRoot != null) {
-      needle.source = util.relative(this.sourceRoot, needle.source);
-    }
-    if (!this._sources.has(needle.source)) {
+    needle.source = this._findSourceIndex(needle.source);
+    if (needle.source < 0) {
       return [];
     }
-    needle.source = this._sources.indexOf(needle.source);
 
     var mappings = [];
 
@@ -337,6 +334,10 @@ function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
   this._names = ArraySet.fromArray(names.map(String), true);
   this._sources = ArraySet.fromArray(sources, true);
 
+  this._absoluteSources = this._sources.toArray().map(function (s) {
+    return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
+  });
+
   this.sourceRoot = sourceRoot;
   this.sourcesContent = sourcesContent;
   this._mappings = mappings;
@@ -348,6 +349,32 @@ BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
 BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
 
 /**
+ * Utility function to find the index of a source.  Returns -1 if not
+ * found.
+ */
+BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) {
+  var relativeSource = aSource;
+  if (this.sourceRoot != null) {
+    relativeSource = util.relative(this.sourceRoot, relativeSource);
+  }
+
+  if (this._sources.has(relativeSource)) {
+    return this._sources.indexOf(relativeSource);
+  }
+
+  // Maybe aSource is an absolute URL as returned by |sources|.  In
+  // this case we can't simply undo the transform.
+  var i;
+  for (i = 0; i < this._absoluteSources.length; ++i) {
+    if (this._absoluteSources[i] == aSource) {
+      return i;
+    }
+  }
+
+  return -1;
+};
+
+/**
  * Create a BasicSourceMapConsumer from a SourceMapGenerator.
  *
  * @param SourceMapGenerator aSourceMap
@@ -367,6 +394,9 @@ BasicSourceMapConsumer.fromSourceMap =
                                                             smc.sourceRoot);
     smc.file = aSourceMap._file;
     smc._sourceMapURL = aSourceMapURL;
+    smc._absoluteSources = smc._sources.toArray().map(function (s) {
+      return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
+    });
 
     // Because we are modifying the entries (by converting string sources and
     // names to indices into the sources and names ArraySets), we have to make
@@ -413,9 +443,7 @@ BasicSourceMapConsumer.prototype._version = 3;
  */
 Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
   get: function () {
-    return this._sources.toArray().map(function (s) {
-      return util.computeSourceURL(this.sourceRoot, s, this._sourceMapURL);
-    }, this);
+    return this._absoluteSources.slice();
   }
 });
 
@@ -685,25 +713,16 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
       return null;
     }
 
+    var index = this._findSourceIndex(aSource);
+    if (index >= 0) {
+      return this.sourcesContent[index];
+    }
+
     var relativeSource = aSource;
     if (this.sourceRoot != null) {
       relativeSource = util.relative(this.sourceRoot, relativeSource);
     }
 
-    if (this._sources.has(relativeSource)) {
-      return this.sourcesContent[this._sources.indexOf(relativeSource)];
-    }
-
-    // Maybe aSource is an absolute URL as returned by |sources|.  In
-    // this case we can't simply undo the transform.
-    var sourceArray = this.sources;
-    var i;
-    for (i = 0; i < sourceArray.length; ++i) {
-      if (sourceArray[i] == aSource) {
-        return this.sourcesContent[i];
-      }
-    }
-
     var url;
     if (this.sourceRoot != null
         && (url = util.urlParse(this.sourceRoot))) {
@@ -761,17 +780,14 @@ BasicSourceMapConsumer.prototype.sourceContentFor =
 BasicSourceMapConsumer.prototype.generatedPositionFor =
   function SourceMapConsumer_generatedPositionFor(aArgs) {
     var source = util.getArg(aArgs, 'source');
-    if (this.sourceRoot != null) {
-      source = util.relative(this.sourceRoot, source);
-    }
-    if (!this._sources.has(source)) {
+    source = this._findSourceIndex(source);
+    if (source < 0) {
       return {
         line: null,
         column: null,
         lastColumn: null
       };
     }
-    source = this._sources.indexOf(source);
 
     var needle = {
       source: source,
@@ -1048,7 +1064,7 @@ IndexedSourceMapConsumer.prototype.generatedPositionFor =
 
       // Only consider this section if the requested source is in the list of
       // sources of the consumer.
-      if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
+      if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) {
         continue;
       }
       var generatedPosition = section.consumer.generatedPositionFor(aArgs);
diff --git a/package.json b/package.json
index 7e64fd2..2466341 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "source-map",
   "description": "Generates and consumes source maps",
-  "version": "0.6.0",
+  "version": "0.6.1",
   "homepage": "https://github.com/mozilla/source-map",
   "author": "Nick Fitzgerald <nfitzgerald at mozilla.com>",
   "contributors": [
diff --git a/test/test-source-map-consumer.js b/test/test-source-map-consumer.js
index 8b59ce7..f101aae 100644
--- a/test/test-source-map-consumer.js
+++ b/test/test-source-map-consumer.js
@@ -498,7 +498,7 @@ exports['test sourceRoot + generatedPositionFor'] = function (assert) {
     generated: { line: 6, column: 6 },
     source: 'bang.coffee'
   });
-  map = new SourceMapConsumer(map.toString());
+  map = new SourceMapConsumer(map.toString(), 'http://example.com/');
 
   // Should handle without sourceRoot.
   var pos = map.generatedPositionFor({
@@ -519,6 +519,16 @@ exports['test sourceRoot + generatedPositionFor'] = function (assert) {
 
   assert.equal(pos.line, 2);
   assert.equal(pos.column, 2);
+
+  // Should handle absolute case.
+  var pos = map.generatedPositionFor({
+    line: 1,
+    column: 1,
+    source: 'http://example.com/foo/bar/bang.coffee'
+  });
+
+  assert.equal(pos.line, 2);
+  assert.equal(pos.column, 2);
 };
 
 exports['test sourceRoot + generatedPositionFor for path above the root'] = function (assert) {
@@ -573,7 +583,7 @@ exports['test allGeneratedPositionsFor for line'] = function (assert) {
     generated: { line: 4, column: 2 },
     source: 'bar.coffee'
   });
-  map = new SourceMapConsumer(map.toString());
+  map = new SourceMapConsumer(map.toString(), 'http://example.com/');
 
   var mappings = map.allGeneratedPositionsFor({
     line: 2,
@@ -585,6 +595,17 @@ exports['test allGeneratedPositionsFor for line'] = function (assert) {
   assert.equal(mappings[0].column, 2);
   assert.equal(mappings[1].line, 3);
   assert.equal(mappings[1].column, 3);
+
+  mappings = map.allGeneratedPositionsFor({
+    line: 2,
+    source: 'http://example.com/bar.coffee'
+  });
+
+  assert.equal(mappings.length, 2);
+  assert.equal(mappings[0].line, 3);
+  assert.equal(mappings[0].column, 2);
+  assert.equal(mappings[1].line, 3);
+  assert.equal(mappings[1].column, 3);
 };
 
 exports['test allGeneratedPositionsFor for line fuzzy'] = function (assert) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-source-map.git



More information about the Pkg-javascript-commits mailing list