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

Commit 2e17f6c

Browse files
committed
wildcard specificity adjustments
1 parent ce7e86b commit 2e17f6c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/system.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function SystemLoader() {
2020
// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
2121
function applyPaths(paths, name) {
2222
// most specific (most number of slashes in path) match wins
23-
var pathMatch = '', wildcard, maxSlashCount = 0;
23+
var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
2424

2525
// check to see if we have a paths entry
2626
for (var p in paths) {
@@ -37,11 +37,11 @@ function applyPaths(paths, name) {
3737
}
3838
// wildcard path match
3939
else {
40-
var slashCount = p.split('/').length;
41-
if (slashCount >= maxSlashCount &&
40+
var wildcardPrefixLen = pathParts[0].length;
41+
if (wildcardPrefixLen >= maxWildcardPrefixLen &&
4242
name.substr(0, pathParts[0].length) == pathParts[0] &&
4343
name.substr(name.length - pathParts[1].length) == pathParts[1]) {
44-
maxSlashCount = slashCount;
44+
maxWildcardPrefixLen = wildcardPrefixLen;
4545
pathMatch = p;
4646
wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
4747
}

0 commit comments

Comments
 (0)