globby icon indicating copy to clipboard operation
globby copied to clipboard

Do not ignore pattern start with `./`

Open zanminkian opened this issue 1 year ago • 2 comments

This PR fix 2 issues:

~~Issue 1: trim gitignore file content~~

Issue 2: pattern starts with ./ or ./ should not be ignored

foo
├── .gitignore ---> content: ./bar.js
└── bar.js ---> should not be ignored, but actually ignored by globby

zanminkian avatar May 14 '24 04:05 zanminkian

  • Handle trailing whitespaces:
  • 'a '(one space) should not match 'a '(two spaces).
  • 'a \ ' matches `'a '

Quote from https://github.com/kaelzhang/node-ignore/tree/master?tab=readme-ov-file#why-another-ignore. It seems spaces are useful.

fisker avatar May 14 '24 06:05 fisker

I'm not pretty sure about issue 1 so I updated this PR.

zanminkian avatar May 15 '24 17:05 zanminkian

Thanks for the PR! However, after thorough testing, I found that the current implementation already handles patterns starting with ./ or ../ correctly, matching Git's behavior.

The ignore library (which globby uses internally) treats patterns starting with ./ as literal patterns that don't match normalized paths, so no code changes are needed.

I've added a test case to document this behavior and prevent future confusion.

sindresorhus avatar Nov 10 '25 19:11 sindresorhus