Skip to content

Commit

Permalink
fix: avoid lazy regexp matching (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosoba authored Dec 2, 2024
1 parent cb577d9 commit c9b413e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function walk(name: string, mapping: Mapping, input: string, options?: t.

if (!!~tmp) {
match = RegExp(
'^' + key.substring(0, tmp) + '(.*)' + key.substring(1+tmp)
'^' + key.substring(0, tmp) + '(.*)' + key.substring(1+tmp) + '$'
).exec(entry);

if (match && match[1]) {
Expand Down
12 changes: 12 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,18 @@ describe('$.imports', it => {
pass(pkg, ['./$foo.require', './$foo.string'], '#foo', { require: true });
pass(pkg, ['./$foo.require', './$foo.string'], 'foobar/#foo', { require: true });
});

// https://github.com/lukeed/resolve.exports/issues/34
it('imports["#features/*"] :: avoid lazy matching', () => {
let pkg: Package = {
name: 'test',
imports: {
'#features/*.css': './src/*.css',
'#features/*.ts': './src/*.ts',
}
};
pass(pkg, './src/asdf/css.ts', '#features/asdf/css.ts');
});
});

describe('$.exports', it => {
Expand Down

0 comments on commit c9b413e

Please sign in to comment.