Skip to content

Commit

Permalink
Fix bug with absolute paths for module IDs in Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
pahen committed Dec 19, 2014
1 parent 7273de9 commit f64697a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/parse/cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ util.inherits(CJS, Base);
* @return {String}
*/
CJS.prototype.normalize = function (filename) {
if (filename.charAt(0) !== '/') {
filename = this.replaceBackslashInPath(filename);
if (!filename.match('/')) {
// a core module (not mapped to a file)
return this.replaceBackslashInPath(filename);
return filename;
}
return Base.prototype.normalize.apply(this, arguments);
};
Expand Down
4 changes: 2 additions & 2 deletions test/pluggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Madge', function () {
var idAdd = "";
var opts = {};
opts.onParseFile = function(obj) {
var arr = obj.filename.split(path.sep);
var arr = obj.filename.split('/');
fileAdd += arr[arr.length-1];
};
opts.onAddModule = function(obj) {
Expand All @@ -26,7 +26,7 @@ describe('Madge', function () {
var idAdd = "";
var opts = {};
opts.onParseFile = function(obj) {
var arr = obj.filename.split(path.sep);
var arr = obj.filename.split('/');
fileAdd += arr[arr.length-1];
};
opts.onAddModule = function(obj) {
Expand Down

0 comments on commit f64697a

Please sign in to comment.