diff --git a/src/utils.ts b/src/utils.ts index ab74868..f0927f9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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]) { diff --git a/test/index.ts b/test/index.ts index 59dcace..1ba0db4 100644 --- a/test/index.ts +++ b/test/index.ts @@ -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 => {