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

Use URLs instead of paths #86

Open
4 tasks done
wooorm opened this issue Jun 21, 2023 · 2 comments
Open
4 tasks done

Use URLs instead of paths #86

wooorm opened this issue Jun 21, 2023 · 2 comments
Labels
🤞 phase/open Post is being triaged manually 💬 type/discussion This is a request for comments

Comments

@wooorm
Copy link
Member

wooorm commented Jun 21, 2023

Initial checklist

Problem

It would be nice to go all in on a format that is supported everywhere: URLs.
Instead of a platform dependent (unix vs windows) string.

However, URLS are broader than what we support, what should we do when URLs point to data:? https://? Etc?
We could change to-vfile -> vfile-fs and add a vfile-fetch too?

Also, URLs as strings are problematic: passing url.href to fs.writeFile will write a file/Users/User/whatever/ folder in CWD. This could be confusing to users.
This means our API has to likely return URL objects instead of strings. But that has again the problem of being either slow or a reference.

It’s a bit harder with URLs to change folders or extensions. Our current getter/setters are a nice alternative.
We could drop those getters/setters, maybe go with some utilities exposed from here to get/set stuff?

Extensions are typically meaningless in URLs anyway. Perhaps we’d need to have mimetypes?

Maybe we could first inspire from, and later depend on / add onto https://developer.mozilla.org/en-US/docs/Web/API/File?

Solution

?

Alternatives

Many!

@wooorm wooorm added the 💬 type/discussion This is a request for comments label Jun 21, 2023
@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jun 21, 2023
@remcohaszing
Copy link
Member

Where exactly? This issue is created specifically on the vfile-message repo, but this package doesn’t use paths.

For reading I think it’s best to follow Node.js logic: A string represents a path, file URLs are also allowed.

I don’t think we need vfile-fetch, but it’s fine to create it.

I’m all for being closer to the standard File API. The downside is that it’s methods are async though.

@wooorm
Copy link
Member Author

wooorm commented Jun 22, 2023

oh whoops was supposed to go in vfile!

@wooorm wooorm transferred this issue from vfile/vfile-message Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 phase/open Post is being triaged manually 💬 type/discussion This is a request for comments
Development

No branches or pull requests

2 participants