sindresorhus / globby

User-friendly glob matching
MIT License
2.51k stars 130 forks source link

Support `URL` as `cwd` #201

Closed fisker closed 2 years ago

fisker commented 2 years ago

I build url-or-path few months ago, it actually accept path, URL and URL.href, should we add test for URL.href too?

Fixes #176

sindresorhus commented 2 years ago

I would prefer not to introduce a dependency for this. I have worked very hard in the past year to reduce the amount of dependencies I use. In this case, it's really just cwd.startsWith('file://') ? fileURLToPath(cwd) : cwd.

sindresorhus commented 2 years ago

I think Node.js should expose a method for this. It's such a common need now that everything is starting to support URL. Maybe you wanna open an issue about it on the Node.js repo?

sindresorhus commented 2 years ago

path.from(string | URL) would be nice API.

fisker commented 2 years ago

Removed dependency, and added test for file: string too.

fisker commented 2 years ago

It's such a common need now that everything is starting to support URL. Maybe you wanna open an issue about it on the Node.js repo?

I think this is a temporary need. Once everything supports URL, convert to path won't be necessary. Anyway, https://github.com/nodejs/node/issues/41521

sindresorhus commented 2 years ago

I think this is a temporary need. Once everything supports URL, convert to path won't be necessary. Anyway,

No, there will always be a need as your argument only works if you directly pass the input to a Node.js API. Many packages manipulate the paths somehow and dealing with path and not URL is much nicer then.