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

Redundant //?/ #568

Closed
tgrajewski opened this issue Nov 3, 2023 · 4 comments
Closed

Redundant //?/ #568

tgrajewski opened this issue Nov 3, 2023 · 4 comments

Comments

@tgrajewski
Copy link

How to get paths with / as separator but without //?/ in returned paths on Windows? This worked before, in v8 I believe.

@isaacs
Copy link
Owner

isaacs commented Nov 3, 2023

As long as the posix: true option has been around, it's been the full UNC path.

This is actually better, since it prevents "path too long" errors in many cases. What is the use case where you want / as the path separator on windows, and full absolute paths, but can't have UNC paths?

@tgrajewski
Copy link
Author

OK, actually I didn't used posix option previously in v8 because I didn't needed. I just tried it in v10 to get forward slashes in the results.

v8 returned results with forward slashes, which was nice, because results matched the pattern "formatting":

> glob.sync('c:/users/tomasz/projects/builder/*.js');
[
  'c:/users/tomasz/projects/builder/builder.js',
  'c:/users/tomasz/projects/builder/index.js'
]

And v10 returns "normalized" paths, which for me is inconvenient:

> glob.sync('c:/users/tomasz/projects/builder/*.js');
[
  'C:\\Users\\Tomasz\\Projects\\builder\\index.js',
  'C:\\Users\\Tomasz\\Projects\\builder\\builder.js'
]

My main use case is to be able to compare glob patterns with forward slashes in them with resulting paths. Often I calculate relative paths of files where the glob pattern starts. I have lot of patterns, all of them are somehow dynamic (concatenated from multiple parts).

So I guess this is more of a complain, but this library requires to use forward slashes in patterns and returns paths that don't match the glob pattern formatting slashes, which requires additional normalizing steps or stripping the UNC thing.

@isaacs
Copy link
Owner

isaacs commented Nov 4, 2023

Would it be more convenient to use { posix: true, relative: true }?

Returning paths with / on windows by default was a frequent complaint about older versions 😅 I'm not opposed to adding an option to strip the unc prefix, just trying to understand the reason for it.

@tgrajewski
Copy link
Author

I guess proper paths on Windows are nice default. My needs are more advanced I suppose. I think I will solve it on my end then, as adding more options and maintaining them adds unnecessary burden on the maintainers.

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

No branches or pull requests

2 participants