fast-glob icon indicating copy to clipboard operation
fast-glob copied to clipboard

There are duplicates when using non-normalized paths in patterns

Open yannvgn opened this issue 5 years ago • 2 comments

Environment

  • OS Version: macOS 10.14
  • Node.js Version: 8.11.4

Actual behavior

The output of fast-glob contains duplicates when using non-normalized paths in patterns (like ./file.txt).

Expected behavior

Duplicates should be avoided.

Steps to reproduce & code sample

Let's assume the working directory contains the following files: file1.txt and file2.txt

fastGlob.sync(['*', './file1.txt'])
// returns ['./file1.txt', 'file2.txt', 'file1.txt']
// where I'm expecting ['file1.txt', 'file2.txt']

I just wanted to raise the issue, though I'm not sure if this is an actual bug or if it's wanted.

Cheers

yannvgn avatar May 22 '19 08:05 yannvgn

Will be covered by fast-glob@3.

mrmlnc avatar Jun 07 '19 19:06 mrmlnc

node-glob does not exclude results from similar patterns.

After several approaches:

  • We don't know which pattern is similar to the other, so we can't drop it from input.
  • In order to say for sure that one path is similar to the other, you need to get the full path (path.resolve). This is a very expensive operation. Unfortunately, I'm not interested in slowing down this place now.

But I understand that this is not a user-friendly way.

I suggest we make the following steps:

  1. In 3.x.x normalize the path in the entry filter when the unique option is enabled. Right now this is the primary cause of the problem (we don't normalize ./).
  2. In 4.x.x back to the discussion of the problem.

Right now moved to 3.1.0.

mrmlnc avatar Jun 16 '19 09:06 mrmlnc

The problem with a leading dot has been solved in the master branch by #402. Other issues will be considered separately as they appear as issues.

Will be shipped with 3.3.0.

mrmlnc avatar May 27 '23 11:05 mrmlnc