Skip to content

Commit 40b8f6f

Browse files
committed
fix: avoid lazy regexp matching
1 parent 2941923 commit 40b8f6f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function walk(name: string, mapping: Mapping, input: string, options?: t.
4444

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

5050
if (match && match[1]) {

test/index.ts

+12
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,18 @@ describe('$.imports', it => {
635635
pass(pkg, ['./$foo.require', './$foo.string'], '#foo', { require: true });
636636
pass(pkg, ['./$foo.require', './$foo.string'], 'foobar/#foo', { require: true });
637637
});
638+
639+
// https://github.com/lukeed/resolve.exports/issues/34
640+
it('imports["#features/*"] :: avoid lazy matching', () => {
641+
let pkg: Package = {
642+
name: 'test',
643+
imports: {
644+
'#features/*.css': './src/*.css',
645+
'#features/*.ts': './src/*.ts',
646+
}
647+
};
648+
pass(pkg, './src/asdf/css.ts', '#features/asdf/css.ts');
649+
});
638650
});
639651

640652
describe('$.exports', it => {

0 commit comments

Comments
 (0)