Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 541c51e

Browse files
committed
Make exact matches win for path lookup
This fixes a bug where when a wildcard path is specified *after* an exact path the wildcard would win. The reason is that for/in loops go in the order that the keys were defined. Deleting the key and readding it shows the error. The fix is simply to break out the loop once we find an exact match. Fixes #189
1 parent bc590de commit 541c51e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/system.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@
235235

236236
// exact path match
237237
if (pathParts.length == 1) {
238-
if (name == p && p.length > pathMatch.length)
238+
if (name == p && p.length > pathMatch.length) {
239239
pathMatch = p;
240+
break;
241+
}
240242
}
241243

242244
// wildcard path match

test/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ function runTests() {
388388
});
389389

390390
test('Custom path most specific', function(assert) {
391+
delete System.paths['bar/*'];
391392
System.paths['bar/bar'] = 'loader/specific-path.js';
393+
System.paths['bar/*'] = 'loader/custom-folder/*.js';
392394
System['import']('bar/bar').then(function(m) {
393395
assert(m.path, true);
394396
});

0 commit comments

Comments
 (0)