|
126 | 126 | } |
127 | 127 |
|
128 | 128 | function _findSourceMappingURL(source) { |
129 | | - var m = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/m.exec(source); |
130 | | - if (m && m[1]) { |
131 | | - return m[1]; |
| 129 | + var sourceMappingUrlRegExp = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/mg; |
| 130 | + var lastSourceMappingUrl; |
| 131 | + var matchSourceMappingUrl; |
| 132 | + while (matchSourceMappingUrl = sourceMappingUrlRegExp.exec(source)) { // jshint ignore:line |
| 133 | + lastSourceMappingUrl = matchSourceMappingUrl[1]; |
| 134 | + } |
| 135 | + if (lastSourceMappingUrl) { |
| 136 | + return lastSourceMappingUrl; |
132 | 137 | } else { |
133 | 138 | throw new Error('sourceMappingURL not found'); |
134 | 139 | } |
|
222 | 227 | * Creating SourceMapConsumers is expensive, so this wraps the creation of a |
223 | 228 | * SourceMapConsumer in a per-instance cache. |
224 | 229 | * |
225 | | - * @param sourceMappingURL = {String} URL to fetch source map from |
226 | | - * @param defaultSourceRoot = Default source root for source map if undefined |
| 230 | + * @param {String} sourceMappingURL = URL to fetch source map from |
| 231 | + * @param {String} defaultSourceRoot = Default source root for source map if undefined |
227 | 232 | * @returns {Promise} that resolves a SourceMapConsumer |
228 | 233 | */ |
229 | 234 | this._getSourceMapConsumer = function _getSourceMapConsumer(sourceMappingURL, defaultSourceRoot) { |
|
321 | 326 | sourceMappingURL = defaultSourceRoot + sourceMappingURL; |
322 | 327 | } |
323 | 328 |
|
324 | | - return this._getSourceMapConsumer(sourceMappingURL, defaultSourceRoot).then(function(sourceMapConsumer) { |
325 | | - return _extractLocationInfoFromSourceMapSource(stackframe, sourceMapConsumer, sourceCache) |
326 | | - .then(resolve)['catch'](function() { |
327 | | - resolve(stackframe); |
| 329 | + return this._getSourceMapConsumer(sourceMappingURL, defaultSourceRoot) |
| 330 | + .then(function(sourceMapConsumer) { |
| 331 | + return _extractLocationInfoFromSourceMapSource(stackframe, sourceMapConsumer, sourceCache) |
| 332 | + .then(resolve)['catch'](function() { |
| 333 | + resolve(stackframe); |
| 334 | + }); |
328 | 335 | }); |
329 | | - }); |
330 | 336 | }.bind(this), reject)['catch'](reject); |
331 | 337 | }.bind(this)); |
332 | 338 | }; |
|
0 commit comments