fix(npm): conditional exports with wildcards (#15652)

This commit is contained in:
Bartek Iwańczuk 2022-08-29 19:15:20 +02:00 committed by GitHub
parent ea838d27a2
commit 2851a98072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 59 additions and 2 deletions

View file

@ -451,7 +451,7 @@ pub fn package_exports_resolve(
for key in package_exports.keys() {
let pattern_index = key.find('*');
if let Some(pattern_index) = pattern_index {
let key_sub = &key[0..=pattern_index];
let key_sub = &key[0..pattern_index];
if package_subpath.starts_with(key_sub) {
// When this reaches EOL, this can throw at the top of the whole function:
//
@ -472,7 +472,7 @@ pub fn package_exports_resolve(
best_match = key;
best_match_subpath = Some(
package_subpath
[pattern_index..=(package_subpath.len() - pattern_trailer.len())]
[pattern_index..(package_subpath.len() - pattern_trailer.len())]
.to_string(),
);
}