@@ -1169,25 +1169,36 @@ The resolver can throw the following errors:
11691169** PACKAGE_IMPORTS_EXPORTS_RESOLVE ** (_matchKey_, _matchObj_, _packageURL_,
11701170_isImports_, _conditions_)
11711171
1172- > 1. If _matchKey_ is a key of _matchObj_, and does not end in _" *" _, then
1172+ > 1. If _matchKey_ is a key of _matchObj_ and does not end in _" /" _ or contain
1173+ > _" *" _, then
11731174> 1. Let _target_ be the value of _matchObj_\[_matchKey_\].
11741175> 1. Let _resolved_ be the result of ** PACKAGE_TARGET_RESOLVE ** (
11751176> _packageURL_, _target_, _" " _, ** false ** , _isImports_, _conditions_).
11761177> 1. Return the object _{resolved, exact: ** true ** }_.
1177- > 1. Let _expansionKeys_ be the list of keys of _matchObj_ ending in _" /" _
1178- > or _" *" _, sorted by length descending.
1178+ > 1. Let _expansionKeys_ be the list of keys of _matchObj_ either ending in
1179+ > _" /" _ or containing only a single _" *" _, sorted by the sorting function
1180+ > **PATTERN_KEY_COMPARE** which orders in descending order of specificity.
11791181> 1. For each key _expansionKey_ in _expansionKeys_, do
1180- > 1. If _expansionKey_ ends in _" *" _ and _matchKey_ starts with but is
1181- > not equal to the substring of _expansionKey_ excluding the last _" *" _
1182- > character, then
1183- > 1. Let _target_ be the value of _matchObj_\[_expansionKey_\].
1184- > 1. Let _subpath_ be the substring of _matchKey_ starting at the
1185- > index of the length of _expansionKey_ minus one.
1186- > 1. Let _resolved_ be the result of ** PACKAGE_TARGET_RESOLVE ** (
1187- > _packageURL_, _target_, _subpath_, ** true ** , _isImports_,
1188- > _conditions_).
1189- > 1. Return the object _{resolved, exact: ** true ** }_.
1190- > 1. If _matchKey_ starts with _expansionKey_, then
1182+ > 1. Let _patternBase_ be **null**.
1183+ > 1. If _expansionKey_ contains _"*"_, set _patternBase_ to the substring of
1184+ > _expansionKey_ up to but excluding the first _"*"_ character.
1185+ > 1. If _patternBase_ is not **null** and _matchKey_ starts with but is not
1186+ > equal to _patternBase_, then
1187+ > 1. Let _patternTrailer_ be the substring of _expansionKey_ from the
1188+ > index after the first _"*"_ character.
1189+ > 1. If _patternTrailer_ has zero length, or if _matchKey_ ends with
1190+ > _patternTrailer_ and the length of _matchKey_ is greater than or
1191+ > equal to the length of _expansionKey_, then
1192+ > 1. Let _target_ be the value of _matchObj_\[_expansionKey_\].
1193+ > 1. Let _subpath_ be the substring of _matchKey_ starting at the
1194+ > index of the length of _patternBase_ up to the length of
1195+ > _matchKey_ minus the length of _patternTrailer_.
1196+ > 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**(
1197+ > _packageURL_ , _target_ , _subpath_ , ** true ** , _isImports_ ,
1198+ > _conditions_ ).
1199+ > 1. Return the object _{resolved, exact: ** true ** }_.
1200+ > 1. Otherwise if _patternBase_ is ** null ** and _matchKey_ starts with
1201+ > _expansionKey_, then
11911202> 1. Let _target_ be the value of _matchObj_\[_expansionKey_\].
11921203> 1. Let _subpath_ be the substring of _matchKey_ starting at the
11931204> index of the length of _expansionKey_.
@@ -1197,6 +1208,22 @@ _isImports_, _conditions_)
11971208> 1. Return the object _{resolved, exact: ** false ** }_.
11981209> 1. Return the object _{resolved: ** null ** , exact: ** true ** }_.
11991210
1211+ ** PATTERN_KEY_COMPARE ** (_keyA_, _keyB_)
1212+
1213+ > 1. Assert: _keyA_ ends with _" /" _ or contains only a single _" *" _.
1214+ > 1. Assert: _keyB_ ends with _" /" _ or contains only a single _" *" _.
1215+ > 1. Let _baseLengthA_ be the index of _" *" _ in _keyA_ plus one, if _keyA_
1216+ > contains _" *" _, or the length of _keyA_ otherwise.
1217+ > 1. Let _baseLengthB_ be the index of _" *" _ in _keyB_ plus one, if _keyB_
1218+ > contains _" *" _, or the length of _keyB_ otherwise.
1219+ > 1. If _baseLengthA_ is greater than _baseLengthB_, return - 1.
1220+ > 1. If _baseLengthB_ is greater than _baseLengthA_, return 1.
1221+ > 1. If _keyA_ does not contain _" *" _, return 1.
1222+ > 1. If _keyB_ does not contain _" *" _, return - 1.
1223+ > 1. If the length of _keyA_ is greater than the length of _keyB_, return - 1.
1224+ > 1. If the length of _keyB_ is greater than the length of _keyA_, return 1.
1225+ > 1. Return 0.
1226+
12001227** PACKAGE_TARGET_RESOLVE ** (_packageURL_, _target_, _subpath_, _pattern_,
12011228_internal_, _conditions_)
12021229
0 commit comments