Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions dist/source-map.debug.js

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions dist/source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,16 @@ return /******/ (function(modules) { // webpackBootstrap
}
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;

/**
* Strip any JSON XSSI avoidance prefix from the string (as documented
* in the source maps specification), and then parse the string as
* JSON.
*/
function parseSourceMapInput(str) {
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
}
exports.parseSourceMapInput = parseSourceMapInput;


/***/ }),
/* 5 */
Expand Down Expand Up @@ -1377,7 +1387,7 @@ return /******/ (function(modules) { // webpackBootstrap
function SourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
sourceMap = util.parseSourceMapInput(aSourceMap);
}

return sourceMap.sections != null
Expand Down Expand Up @@ -1652,7 +1662,7 @@ return /******/ (function(modules) { // webpackBootstrap
function BasicSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
sourceMap = util.parseSourceMapInput(aSourceMap);
}

var version = util.getArg(sourceMap, 'version');
Expand Down Expand Up @@ -2205,7 +2215,7 @@ return /******/ (function(modules) { // webpackBootstrap
function IndexedSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
sourceMap = util.parseSourceMapInput(aSourceMap);
}

var version = util.getArg(sourceMap, 'version');
Expand Down
2 changes: 1 addition & 1 deletion dist/source-map.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/source-map.min.js.map

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions dist/test/test_api.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion dist/test/test_array_set.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions dist/test/test_dog_fooding.js

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions dist/test/test_source_map_consumer.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions dist/test/test_source_map_generator.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions dist/test/test_source_node.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion dist/test/test_util.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/source-map-consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var quickSort = require('./quick-sort').quickSort;
function SourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: if you reuse the same regexp (see below), please note that only the parens needs escaping.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did do it this way fwiw.

sourceMap = util.parseSourceMapInput(aSourceMap);
}

return sourceMap.sections != null
Expand Down Expand Up @@ -289,7 +289,7 @@ exports.SourceMapConsumer = SourceMapConsumer;
function BasicSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
sourceMap = util.parseSourceMapInput(aSourceMap);
}

var version = util.getArg(sourceMap, 'version');
Expand Down Expand Up @@ -842,7 +842,7 @@ exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
function IndexedSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
sourceMap = util.parseSourceMapInput(aSourceMap);
}

var version = util.getArg(sourceMap, 'version');
Expand Down
10 changes: 10 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,13 @@ function compareByGeneratedPositionsInflated(mappingA, mappingB) {
return strcmp(mappingA.name, mappingB.name);
}
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;

/**
* Strip any JSON XSSI avoidance prefix from the string (as documented
* in the source maps specification), and then parse the string as
* JSON.
*/
function parseSourceMapInput(str) {
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ''));
}
exports.parseSourceMapInput = parseSourceMapInput;
2 changes: 1 addition & 1 deletion test/test-source-map-consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ exports['test mappings and end of lines'] = function (assert) {

exports['test creating source map consumers with )]}\' prefix'] = function (assert) {
assert.doesNotThrow(function () {
var map = new SourceMapConsumer(")]}'" + JSON.stringify(util.testMap));
var map = new SourceMapConsumer(")]}'\n" + JSON.stringify(util.testMap));
});
};

Expand Down