diff --git a/source-map-support.js b/source-map-support.js index 45d824c..7ef6a56 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -46,6 +46,7 @@ function retrieveFile(path) { // Support URLs relative to a directory, but be careful about a protocol prefix // in case we are in the browser (i.e. directories may start with "http://") function supportRelativeURL(file, url) { + if (!file) return url; var dir = path.dirname(file); var match = /^\w+:\/\/[^\/]*/.exec(dir); var protocol = match ? match[0] : ''; @@ -122,10 +123,8 @@ function mapSourcePosition(position) { // better to give a precise location in the compiled file than a vague // location in the original file. if (originalPosition.source !== null) { - if (sourceMap.url) { - originalPosition.source = supportRelativeURL( - sourceMap.url, originalPosition.source); - } + originalPosition.source = supportRelativeURL( + sourceMap.url, originalPosition.source); return originalPosition; } } diff --git a/test.js b/test.js index ec016f8..8b3fbf3 100644 --- a/test.js +++ b/test.js @@ -241,6 +241,15 @@ it('throw with source map with gap', function() { ]); }); +it('sourcesContent with data URL', function() { + compareStackTrace(createMultiLineSourceMapWithSourcesContent(), [ + 'throw new Error("test");' + ], [ + 'Error: test', + /^ at Object\.exports\.test \(.*\/original.js:1001:5\)$/ + ]); +}); + it('default options', function(done) { compareStdout(done, createSingleLineSourceMap(), [ '',