Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Do not output "undefined" if more mappings than lines. #1

Merged
merged 1 commit into from
Mar 7, 2016
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
1 change: 1 addition & 0 deletions lib/fromStringWithSourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = function fromStringWithSourceMap(code, map) {
var currentSourceNodeLine;
mappings.forEach(function(mapping, idx) {
var line = lines[idx];
if(typeof line === 'undefined') return;
if(idx !== lines.length - 1) line += "\n";
if(!mapping)
return addCode(line);
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/from-to-tests/mismatched-mappings.expected.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 3,
"file": "mismatched-mappings.generated.txt",
"sources": [
"hello-world.txt"
],
"sourcesContent": [
"function foobar() {\n return; // foo\n}"
],
"mappings": "AAAA;AACA;AADA"
}
3 changes: 3 additions & 0 deletions test/fixtures/from-to-tests/mismatched-mappings.generated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function foobar() {
return; // foo
}
11 changes: 11 additions & 0 deletions test/fixtures/from-to-tests/mismatched-mappings.input.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 3,
"file": "mismatched-mappings.generated.txt",
"sources": [
"hello-world.txt"
],
"sourcesContent": [
"function foobar() {\n return; // foo\n}"
],
"mappings": "AAAA,SAAS,MAAT,GAAmB;AACjB;CADF;AAAmB"
}