Skip to content

Commit

Permalink
fix: check subpattern length correctly;
Browse files Browse the repository at this point in the history
- Closes lukeed#4
  • Loading branch information
lukeed committed Jan 12, 2021
1 parent bd8eacf commit 81ae07a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function resolve(pkg, entry='.', options={}) {
}
if (tmp === '*' && target.startsWith(key.slice(0, -1))) {
// do not trigger if no *content* to inject
if (target.length - key.length > 1) {
if (target.substring(key.length - 1).length > 0) {
return (tmp = loop(exports[key], allows))
? tmp.replace('*', target.substring(key.length - 1))
: bail(name, target, 1);
Expand Down
4 changes: 4 additions & 0 deletions test/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ resolve('exports["./features/*"]', () => {
fail(pkg, './features/', 'features/');
fail(pkg, './features/', 'foobar/features/');

pass(pkg, './features/a.js', 'foobar/features/a');
pass(pkg, './features/ab.js', 'foobar/features/ab');
pass(pkg, './features/abc.js', 'foobar/features/abc');

pass(pkg, './features/hello.js', 'foobar/features/hello');
pass(pkg, './features/world.js', 'foobar/features/world');

Expand Down

0 comments on commit 81ae07a

Please sign in to comment.