Skip to content

Incorrect substitution with multiple * wildcards #9

Closed
@evanw

Description

@evanw

I looked at this library briefly when I implemented this feature for esbuild and discovered some bugs. One of them is that it looks like this library doesn't handle * wildcards correctly when there are multiple wildcards:

const re = require('resolve.exports')
const pkg = {
  exports: {
    "./dir*": "./*sub/dir*/file.js"
  }
}
console.log(re.resolve(pkg, 'dirtest'))

Expected output:

./testsub/dirtest/file.js

Observed output:

./testsub/dir*/file.js

The relevant part from the spec is this one:

  1. If pattern is true, then
    1. Return the URL resolution of resolvedTarget with every instance of "*" replaced with subpath.

Other bugs I found included #7 and missing validation checks. I wasn't sure whether to also file a bug about the missing validation checks since you could argue that it's potentially not a concern of this library, although if many tools are adopting this package then it would probably make sense to put the validation checks in one place instead of replicating them in the various projects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions