be careful about a null url for data URLs

master
Evan Wallace 11 years ago
parent 7fa445e16f
commit 649da9a3e5

@ -46,6 +46,7 @@ function retrieveFile(path) {
// Support URLs relative to a directory, but be careful about a protocol prefix // 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://") // in case we are in the browser (i.e. directories may start with "http://")
function supportRelativeURL(file, url) { function supportRelativeURL(file, url) {
if (!file) return url;
var dir = path.dirname(file); var dir = path.dirname(file);
var match = /^\w+:\/\/[^\/]*/.exec(dir); var match = /^\w+:\/\/[^\/]*/.exec(dir);
var protocol = match ? match[0] : ''; 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 // better to give a precise location in the compiled file than a vague
// location in the original file. // location in the original file.
if (originalPosition.source !== null) { if (originalPosition.source !== null) {
if (sourceMap.url) {
originalPosition.source = supportRelativeURL( originalPosition.source = supportRelativeURL(
sourceMap.url, originalPosition.source); sourceMap.url, originalPosition.source);
}
return originalPosition; return originalPosition;
} }
} }

@ -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) { it('default options', function(done) {
compareStdout(done, createSingleLineSourceMap(), [ compareStdout(done, createSingleLineSourceMap(), [
'', '',

Loading…
Cancel
Save