Skip to content

Commit d730e6b

Browse files
authored
Merge pull request mozilla#276 from tromey/fix-hyphen
Correctly parse URL where host includes "-"
2 parents 2a808d9 + 215590b commit d730e6b

17 files changed

+606
-346
lines changed

dist/source-map.debug.js

Lines changed: 79 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/source-map.js

Lines changed: 78 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ return /******/ (function(modules) { // webpackBootstrap
5252
/************************************************************************/
5353
/******/ ([
5454
/* 0 */
55-
/***/ function(module, exports, __webpack_require__) {
55+
/***/ (function(module, exports, __webpack_require__) {
5656

5757
/*
5858
* Copyright 2009-2011 Mozilla Foundation and contributors
@@ -64,9 +64,9 @@ return /******/ (function(modules) { // webpackBootstrap
6464
exports.SourceNode = __webpack_require__(10).SourceNode;
6565

6666

67-
/***/ },
67+
/***/ }),
6868
/* 1 */
69-
/***/ function(module, exports, __webpack_require__) {
69+
/***/ (function(module, exports, __webpack_require__) {
7070

7171
/* -*- Mode: js; js-indent-level: 2; -*- */
7272
/*
@@ -329,6 +329,18 @@ return /******/ (function(modules) { // webpackBootstrap
329329
SourceMapGenerator.prototype._validateMapping =
330330
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
331331
aName) {
332+
// When aOriginal is truthy but has empty values for .line and .column,
333+
// it is most likely a programmer error. In this case we throw a very
334+
// specific error message to try to guide them the right way.
335+
// For example: https://github.com/Polymer/polymer-bundler/pull/519
336+
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
337+
throw new Error(
338+
'original.line and original.column are not numbers -- you probably meant to omit ' +
339+
'the original mapping entirely and only map the generated position. If so, pass ' +
340+
'null for the original mapping instead of an object with empty or null values.'
341+
);
342+
}
343+
332344
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
333345
&& aGenerated.line > 0 && aGenerated.column >= 0
334346
&& !aOriginal && !aSource && !aName) {
@@ -474,9 +486,9 @@ return /******/ (function(modules) { // webpackBootstrap
474486
exports.SourceMapGenerator = SourceMapGenerator;
475487

476488

477-
/***/ },
489+
/***/ }),
478490
/* 2 */
479-
/***/ function(module, exports, __webpack_require__) {
491+
/***/ (function(module, exports, __webpack_require__) {
480492

481493
/* -*- Mode: js; js-indent-level: 2; -*- */
482494
/*
@@ -620,9 +632,9 @@ return /******/ (function(modules) { // webpackBootstrap
620632
};
621633

622634

623-
/***/ },
635+
/***/ }),
624636
/* 3 */
625-
/***/ function(module, exports) {
637+
/***/ (function(module, exports) {
626638

627639
/* -*- Mode: js; js-indent-level: 2; -*- */
628640
/*
@@ -693,9 +705,9 @@ return /******/ (function(modules) { // webpackBootstrap
693705
};
694706

695707

696-
/***/ },
708+
/***/ }),
697709
/* 4 */
698-
/***/ function(module, exports) {
710+
/***/ (function(module, exports) {
699711

700712
/* -*- Mode: js; js-indent-level: 2; -*- */
701713
/*
@@ -725,7 +737,7 @@ return /******/ (function(modules) { // webpackBootstrap
725737
}
726738
exports.getArg = getArg;
727739

728-
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
740+
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(\S*)$/;
729741
var dataUrlRegexp = /^data:.+\,.+$/;
730742

731743
function urlParse(aUrl) {
@@ -768,7 +780,7 @@ return /******/ (function(modules) { // webpackBootstrap
768780
/**
769781
* Normalizes a path, or the path portion of a URL:
770782
*
771-
* - Replaces consequtive slashes with one slash.
783+
* - Replaces consecutive slashes with one slash.
772784
* - Removes unnecessary '.' parts.
773785
* - Removes unnecessary '<dir>/..' parts.
774786
*
@@ -1116,9 +1128,9 @@ return /******/ (function(modules) { // webpackBootstrap
11161128
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
11171129

11181130

1119-
/***/ },
1131+
/***/ }),
11201132
/* 5 */
1121-
/***/ function(module, exports, __webpack_require__) {
1133+
/***/ (function(module, exports, __webpack_require__) {
11221134

11231135
/* -*- Mode: js; js-indent-level: 2; -*- */
11241136
/*
@@ -1129,6 +1141,7 @@ return /******/ (function(modules) { // webpackBootstrap
11291141

11301142
var util = __webpack_require__(4);
11311143
var has = Object.prototype.hasOwnProperty;
1144+
var hasNativeMap = typeof Map !== "undefined";
11321145

11331146
/**
11341147
* A data structure which is a combination of an array and a set. Adding a new
@@ -1138,7 +1151,7 @@ return /******/ (function(modules) { // webpackBootstrap
11381151
*/
11391152
function ArraySet() {
11401153
this._array = [];
1141-
this._set = Object.create(null);
1154+
this._set = hasNativeMap ? new Map() : Object.create(null);
11421155
}
11431156

11441157
/**
@@ -1159,7 +1172,7 @@ return /******/ (function(modules) { // webpackBootstrap
11591172
* @returns Number
11601173
*/
11611174
ArraySet.prototype.size = function ArraySet_size() {
1162-
return Object.getOwnPropertyNames(this._set).length;
1175+
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
11631176
};
11641177

11651178
/**
@@ -1168,14 +1181,18 @@ return /******/ (function(modules) { // webpackBootstrap
11681181
* @param String aStr
11691182
*/
11701183
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
1171-
var sStr = util.toSetString(aStr);
1172-
var isDuplicate = has.call(this._set, sStr);
1184+
var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
1185+
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
11731186
var idx = this._array.length;
11741187
if (!isDuplicate || aAllowDuplicates) {
11751188
this._array.push(aStr);
11761189
}
11771190
if (!isDuplicate) {
1178-
this._set[sStr] = idx;
1191+
if (hasNativeMap) {
1192+
this._set.set(aStr, idx);
1193+
} else {
1194+
this._set[sStr] = idx;
1195+
}
11791196
}
11801197
};
11811198

@@ -1185,8 +1202,12 @@ return /******/ (function(modules) { // webpackBootstrap
11851202
* @param String aStr
11861203
*/
11871204
ArraySet.prototype.has = function ArraySet_has(aStr) {
1188-
var sStr = util.toSetString(aStr);
1189-
return has.call(this._set, sStr);
1205+
if (hasNativeMap) {
1206+
return this._set.has(aStr);
1207+
} else {
1208+
var sStr = util.toSetString(aStr);
1209+
return has.call(this._set, sStr);
1210+
}
11901211
};
11911212

11921213
/**
@@ -1195,10 +1216,18 @@ return /******/ (function(modules) { // webpackBootstrap
11951216
* @param String aStr
11961217
*/
11971218
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
1198-
var sStr = util.toSetString(aStr);
1199-
if (has.call(this._set, sStr)) {
1200-
return this._set[sStr];
1219+
if (hasNativeMap) {
1220+
var idx = this._set.get(aStr);
1221+
if (idx >= 0) {
1222+
return idx;
1223+
}
1224+
} else {
1225+
var sStr = util.toSetString(aStr);
1226+
if (has.call(this._set, sStr)) {
1227+
return this._set[sStr];
1228+
}
12011229
}
1230+
12021231
throw new Error('"' + aStr + '" is not in the set.');
12031232
};
12041233

@@ -1226,9 +1255,9 @@ return /******/ (function(modules) { // webpackBootstrap
12261255
exports.ArraySet = ArraySet;
12271256

12281257

1229-
/***/ },
1258+
/***/ }),
12301259
/* 6 */
1231-
/***/ function(module, exports, __webpack_require__) {
1260+
/***/ (function(module, exports, __webpack_require__) {
12321261

12331262
/* -*- Mode: js; js-indent-level: 2; -*- */
12341263
/*
@@ -1311,9 +1340,9 @@ return /******/ (function(modules) { // webpackBootstrap
13111340
exports.MappingList = MappingList;
13121341

13131342

1314-
/***/ },
1343+
/***/ }),
13151344
/* 7 */
1316-
/***/ function(module, exports, __webpack_require__) {
1345+
/***/ (function(module, exports, __webpack_require__) {
13171346

13181347
/* -*- Mode: js; js-indent-level: 2; -*- */
13191348
/*
@@ -2399,9 +2428,9 @@ return /******/ (function(modules) { // webpackBootstrap
23992428
exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
24002429

24012430

2402-
/***/ },
2431+
/***/ }),
24032432
/* 8 */
2404-
/***/ function(module, exports) {
2433+
/***/ (function(module, exports) {
24052434

24062435
/* -*- Mode: js; js-indent-level: 2; -*- */
24072436
/*
@@ -2516,9 +2545,9 @@ return /******/ (function(modules) { // webpackBootstrap
25162545
};
25172546

25182547

2519-
/***/ },
2548+
/***/ }),
25202549
/* 9 */
2521-
/***/ function(module, exports) {
2550+
/***/ (function(module, exports) {
25222551

25232552
/* -*- Mode: js; js-indent-level: 2; -*- */
25242553
/*
@@ -2636,9 +2665,9 @@ return /******/ (function(modules) { // webpackBootstrap
26362665
};
26372666

26382667

2639-
/***/ },
2668+
/***/ }),
26402669
/* 10 */
2641-
/***/ function(module, exports, __webpack_require__) {
2670+
/***/ (function(module, exports, __webpack_require__) {
26422671

26432672
/* -*- Mode: js; js-indent-level: 2; -*- */
26442673
/*
@@ -2702,13 +2731,19 @@ return /******/ (function(modules) { // webpackBootstrap
27022731
// All even indices of this array are one line of the generated code,
27032732
// while all odd indices are the newlines between two adjacent lines
27042733
// (since `REGEX_NEWLINE` captures its match).
2705-
// Processed fragments are removed from this array, by calling `shiftNextLine`.
2734+
// Processed fragments are accessed by calling `shiftNextLine`.
27062735
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
2736+
var remainingLinesIndex = 0;
27072737
var shiftNextLine = function() {
2708-
var lineContents = remainingLines.shift();
2738+
var lineContents = getNextLine();
27092739
// The last line of a file might not have a newline.
2710-
var newLine = remainingLines.shift() || "";
2740+
var newLine = getNextLine() || "";
27112741
return lineContents + newLine;
2742+
2743+
function getNextLine() {
2744+
return remainingLinesIndex < remainingLines.length ?
2745+
remainingLines[remainingLinesIndex++] : undefined;
2746+
}
27122747
};
27132748

27142749
// We need to remember the position of "remainingLines"
@@ -2733,10 +2768,10 @@ return /******/ (function(modules) { // webpackBootstrap
27332768
// There is no new line in between.
27342769
// Associate the code between "lastGeneratedColumn" and
27352770
// "mapping.generatedColumn" with "lastMapping"
2736-
var nextLine = remainingLines[0];
2771+
var nextLine = remainingLines[remainingLinesIndex];
27372772
var code = nextLine.substr(0, mapping.generatedColumn -
27382773
lastGeneratedColumn);
2739-
remainingLines[0] = nextLine.substr(mapping.generatedColumn -
2774+
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
27402775
lastGeneratedColumn);
27412776
lastGeneratedColumn = mapping.generatedColumn;
27422777
addMappingWithCode(lastMapping, code);
@@ -2753,21 +2788,21 @@ return /******/ (function(modules) { // webpackBootstrap
27532788
lastGeneratedLine++;
27542789
}
27552790
if (lastGeneratedColumn < mapping.generatedColumn) {
2756-
var nextLine = remainingLines[0];
2791+
var nextLine = remainingLines[remainingLinesIndex];
27572792
node.add(nextLine.substr(0, mapping.generatedColumn));
2758-
remainingLines[0] = nextLine.substr(mapping.generatedColumn);
2793+
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
27592794
lastGeneratedColumn = mapping.generatedColumn;
27602795
}
27612796
lastMapping = mapping;
27622797
}, this);
27632798
// We have processed all mappings.
2764-
if (remainingLines.length > 0) {
2799+
if (remainingLinesIndex < remainingLines.length) {
27652800
if (lastMapping) {
27662801
// Associate the remaining code in the current line with "lastMapping"
27672802
addMappingWithCode(lastMapping, shiftNextLine());
27682803
}
27692804
// and add the remaining lines without any mapping
2770-
node.add(remainingLines.join(""));
2805+
node.add(remainingLines.splice(remainingLinesIndex).join(""));
27712806
}
27722807

27732808
// Copy sourcesContent into SourceNode
@@ -3049,7 +3084,7 @@ return /******/ (function(modules) { // webpackBootstrap
30493084
exports.SourceNode = SourceNode;
30503085

30513086

3052-
/***/ }
3087+
/***/ })
30533088
/******/ ])
30543089
});
30553090
;

dist/source-map.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/source-map.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)