Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
ensure wildcard paths canonicalize with extension
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Feb 1, 2016
1 parent 28010b9 commit d2313fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function getCanonicalNamePlain(loader, normalized, isPlugin) {
continue;

// normalize the output path
var curPath = normalizePath(loader, p, isPlugin);
var curPath = normalizePath(loader, p, true);

// do reverse match
var wIndex = curPath.indexOf('*');
Expand Down Expand Up @@ -267,13 +267,13 @@ function getPackage(packages, name) {
}

var absURLRegEx = /^[^\/]+:\/\//;
function normalizePath(loader, path, isPlugin) {
function normalizePath(loader, path, skipExtension) {
var curPath;
if (loader.paths[path][0] == '.')
curPath = decodeURI(url.resolve(toFileURL(process.cwd()) + '/', loader.paths[path]));
else
curPath = decodeURI(url.resolve(loader.baseURL, loader.paths[path]));
if (loader.defaultJSExtensions && !isPlugin && curPath.substr(curPath.length - 3, 3) != '.js')
if (loader.defaultJSExtensions && !skipExtension && curPath.substr(curPath.length - 3, 3) != '.js')
curPath += '.js';
return curPath;
}
Expand Down
2 changes: 1 addition & 1 deletion test/canonicals.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ suite('Canonical Names', function() {
test('Wildcard extensions with a plugin', function() {
builder.loader.defaultJSExtensions = true;
assert.equal(builder.getCanonicalName('cjs'), 'cjs');
assert.equal(builder.getCanonicalName(baseURL + 'test/dummy/file.jade!' + baseURL + 'test/fixtures/test-tree/jade.js'), 'file.jade!jade');
assert.equal(builder.getCanonicalName(baseURL + 'test/dummy/file.jade!' + baseURL + 'test/fixtures/test-tree/jade.js'), 'file.jade!jade.js');
});

test('Trailing / canonical', function() {
Expand Down

0 comments on commit d2313fe

Please sign in to comment.