globby
globby copied to clipboard
Do not ignore pattern start with `./`
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
- 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.
I'm not pretty sure about issue 1 so I updated this PR.
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.