Due to a usage limitation in @gerhobbelt/gitignore-parser, directory patterns with a trailing slash in the .filenignore do not work as expected. This PR fixes this issue.
Details
The .gitignore syntax utilized for the .filenignore syntax supports three different ways of excluding directories.
/dir will match a file, directory, link, anything named dir
/dir/ will match only a directory named dir
/dir/* will match all files, directories and anything else inside a directory named dir (but not the dir directory itself).
The second item of the list above is not currently supported by Filen, resulting in the directory /dir/ to still be uploaded. This happens, because @gerhobbelt/gitignore-parser cannot deduce whether a path is a directory or file when matching it against the pattern. The proposed solution is to append directory paths with a trailing slash, see https://www.npmjs.com/package/@gerhobbelt/gitignore-parser#notes
Implementation
Here, I have sought out (I believe) all usages of @gerhobbelt/gitignore-parser and before passing a path to the denies method, added a trailing slash, if the path is a directory.
I tested the changes locally and found the changes to have the desired effects. Nevertheless, I encourage formal testing as I could not find a testsuite and only build and tested the application on windows. I welcome suggestions for edits.
Due to a usage limitation in
@gerhobbelt/gitignore-parser
, directory patterns with a trailing slash in the .filenignore do not work as expected. This PR fixes this issue.Details
The .gitignore syntax utilized for the .filenignore syntax supports three different ways of excluding directories.
Source: https://stackoverflow.com/questions/17888695/#answer-38559600
The second item of the list above is not currently supported by Filen, resulting in the directory
/dir/
to still be uploaded. This happens, because@gerhobbelt/gitignore-parser
cannot deduce whether a path is a directory or file when matching it against the pattern. The proposed solution is to append directory paths with a trailing slash, see https://www.npmjs.com/package/@gerhobbelt/gitignore-parser#notesImplementation
Here, I have sought out (I believe) all usages of
@gerhobbelt/gitignore-parser
and before passing a path to thedenies
method, added a trailing slash, if the path is a directory.I tested the changes locally and found the changes to have the desired effects. Nevertheless, I encourage formal testing as I could not find a testsuite and only build and tested the application on windows. I welcome suggestions for edits.