gitignore-parser
gitignore-parser copied to clipboard
gitignore `/a` should differ from 'a'
https://git-scm.com/docs/gitignore#_pattern_format
If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.
[...]
For example, a pattern doc/frotz/ matches doc/frotz directory, but not a/doc/frotz directory; however frotz/ matches frotz and a/frotz that is a directory (all paths are relative from the .gitignore file).
Now gitignore-parser creates regexes for both which are wrong: only the /a should become /^a/ while a should be turned into a regex like /a/ (or possibly /(^|[\/])a/ ...)