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

Commit

Permalink
wildcard specificity adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Sep 24, 2015
1 parent ce7e86b commit 2e17f6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/system.js
Expand Up @@ -20,7 +20,7 @@ function SystemLoader() {
// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
function applyPaths(paths, name) {
// most specific (most number of slashes in path) match wins
var pathMatch = '', wildcard, maxSlashCount = 0;
var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;

// check to see if we have a paths entry
for (var p in paths) {
Expand All @@ -37,11 +37,11 @@ function applyPaths(paths, name) {
}
// wildcard path match
else {
var slashCount = p.split('/').length;
if (slashCount >= maxSlashCount &&
var wildcardPrefixLen = pathParts[0].length;
if (wildcardPrefixLen >= maxWildcardPrefixLen &&
name.substr(0, pathParts[0].length) == pathParts[0] &&
name.substr(name.length - pathParts[1].length) == pathParts[1]) {
maxSlashCount = slashCount;
maxWildcardPrefixLen = wildcardPrefixLen;
pathMatch = p;
wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
}
Expand Down

0 comments on commit 2e17f6c

Please sign in to comment.