Skip to content

Commit

Permalink
normalize the base path as well as the filename for sourcemaps. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Dec 17, 2013
1 parent 117262d commit 381fb98
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/less/source-map-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
this._sourceMapFilename = options.sourceMapFilename;
this._outputFilename = options.outputFilename;
this._sourceMapURL = options.sourceMapURL;
this._sourceMapBasepath = options.sourceMapBasepath;
if (this._sourceMapBasepath) {
this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/');
}
this._sourceMapRootpath = options.sourceMapRootpath;
this._outputSourceFiles = options.outputSourceFiles;
this._sourceMapGeneratorConstructor = options.sourceMapGenerator || require("source-map").SourceMapGenerator;
Expand All @@ -22,13 +24,14 @@
};

tree.sourceMapOutput.prototype.normalizeFilename = function(filename) {
filename = filename.replace(/\\/g, '/');
if (this._sourceMapBasepath && filename.indexOf(this._sourceMapBasepath) === 0) {
filename = filename.substring(this._sourceMapBasepath.length);
if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') {
filename = filename.substring(1);
}
filename = filename.substring(this._sourceMapBasepath.length);
if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') {
filename = filename.substring(1);
}
}
return (this._sourceMapRootpath || "") + filename.replace(/\\/g, '/');
return (this._sourceMapRootpath || "") + filename;
};

tree.sourceMapOutput.prototype.add = function(chunk, fileInfo, index, mapLines) {
Expand Down

0 comments on commit 381fb98

Please sign in to comment.