Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing backslash in the ignore file is throwing a syntax error. #81

Closed
wkozyra95 opened this issue Aug 23, 2022 · 1 comment · May be fixed by https-github-com-okeamah/jetpack-master#6
Labels

Comments

@wkozyra95
Copy link

import ignore from 'ignore'
ignore().add('test\\').ignores('test')

The above code will throw

SyntaxError: Invalid regular expression: /(?:^|\/)test\(?=$|\/$)/: Unmatched ')'

I'm not sure what the correct behavior should be according to standard, but it does not fail in git so I would also expect this case to be handled without throwing an error. For now I'm just handling that case by striping trailing '', before it's passed to ignore.

@kaelzhang
Copy link
Owner

kaelzhang commented Dec 19, 2022

I think test\\ is an invalid gitignore pattern, however it indicates a bug of node-ignore that node-ignore should not throw

But you should not strip trailing ' ' of gitignore patterns, and trailing whitespaces are already handled by node-ignore according to the gitignore spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants