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

feat: add pathsep option #475

Closed
wants to merge 1 commit into from

Conversation

nicolas377
Copy link

This is the first part of the implementation of #468. This PR implements the pathsep option, which is intended to allow users to specify the path separator used in the glob pattern.

@@ -83,6 +83,11 @@ function setopts (self, pattern, options) {
self.statCache = options.statCache || Object.create(null)
self.symlinks = options.symlinks || Object.create(null)

// avoiding empty strings
if (!!options.pathsep) {
pattern = pattern.split(options.pathsep).join("/")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While using String.prototype.replace with a plain RegExp with the g flag (String.prototype.replaceAll isn't supported on node v12 and v14) is significantly faster than splitting and joining strings, creating a RegExp from dynamic content poses both security risks and can throw incorrect errors when a single backslash is inputted.

Escaping potentially dangerous characters will put a large load on one point security-wise, and is less performant than simply splitting and joining strings.

@isaacs
Copy link
Owner

isaacs commented Mar 1, 2023

No longer relevant, landed on windowsPathsNoEscape option.

@isaacs isaacs closed this Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants