Trailing slash discrepancy with micromatch · Issue #20 · micromatch/nanomatch · GitHub
Skip to content

Trailing slash discrepancy with micromatch #20

Open

Description

@sbellone

Please describe the minimum necessary steps to reproduce this issue:

const micromatch = require('micromatch'); // version must be >= 4.0.1
console.log(micromatch(['/test/t/'], ['**/t/']));
// [ '/test/t/' ]
console.log(micromatch(['/test/t/'], ['**/t']));
// []

const nm = require('nanomatch');
console.log(nm(['/test/t/'], ['**/t/']));
// [ '/test/t/' ]
console.log(nm(['/test/t/'], ['**/t']));
// [ '/test/t/' ]

What is happening:

micromatch takes into account the trailing slash and do an exact match
nanomatch doesn't take it into account and match even without trailing slash in the pattern

What should be happening instead?

Both libraries should be aligned on this behaviour. From this previous issue on micromatch about trailing slashes, I believe we will want the fix to be done here in nanomatch.

Additional info

As micromatch switched from nanomatch to picomatch in v4.x (during this refactor), micromatch's behaviour has actually changed between v3.1.10 and v4.0.1. It was previously behaving like nanomatch.
Again, after reading the discussion about the trailing slashes linked above, I believe we want to keep its new behaviour, so an additional unit test could be added in micromatch to be sure to stay consistent in the future.

Activity

  1. jonschlinkert commented on Apr 16, 2019

    @jonschlinkert
    Member

    Both libraries should be aligned on this behaviour

    Why?

  2. sbellone commented on Apr 16, 2019

    @sbellone
    Author

    Oh, I assumed that because in the description it states to be "Similar to micromatch", and because they have been aligned until last week (as micromatch was depending on it, I imagine).

    Also it's a matter of having consistent behaviours inside the lib itself actually. If I take an example similar to the one from the linked discussion, I get this behaviour:

    const nm = require('nanomatch');
    console.log(nm(['t/'], ['t/']));
    // [ 't/' ]
    console.log(nm(['t/'], ['t']));
    // []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions