Skip to content
Open
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
26 changes: 13 additions & 13 deletions browser-source-map-support.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions source-map-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ function supportRelativeURL(file, url) {
var match = /^\w+:\/\/[^\/]*/.exec(dir);
var protocol = match ? match[0] : '';
var startPath = dir.slice(protocol.length);
var urlPath = url.startsWith(protocol) ? url.slice(protocol.length) : url;
var absolutePath = path.resolve(startPath, urlPath)
if (protocol && /^\/\w\:/.test(startPath)) {
// handle file:///C:/ paths
protocol += '/';
return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
return protocol + absolutePath.replace(/\\/g, '/');
}
return protocol + path.resolve(dir.slice(protocol.length), url);
return protocol + absolutePath;
}

function retrieveSourceMapURL(source) {
Expand Down Expand Up @@ -524,6 +526,7 @@ exports.wrapCallSite = wrapCallSite;
exports.getErrorSource = getErrorSource;
exports.mapSourcePosition = mapSourcePosition;
exports.retrieveSourceMap = retrieveSourceMap;
exports.supportRelativeURL = supportRelativeURL;

exports.install = function(options) {
options = options || {};
Expand Down
11 changes: 10 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require('./source-map-support').install({
var sourceMapSupport = require('./source-map-support');
sourceMapSupport.install({
emptyCacheBetweenOperations: true // Needed to be able to test for failure
});

Expand Down Expand Up @@ -661,3 +662,11 @@ it('normal console.trace', function(done) {
/^ at Object\.<anonymous> \((?:.*[/\\])?line2\.js:1002:102\)$/
]);
});

it('supports absolute source map urls', function() {
var sourceMapUrl = sourceMapSupport.supportRelativeURL(
'http://127.0.0.1:1336/chunk/chunk.js',
'http://127.0.0.1:1336/chunk/chunk.js.map',
);
assert.equal(sourceMapUrl, 'http://127.0.0.1:1336/chunk/chunk.js.map');
});