socket icon indicating copy to clipboard operation
socket copied to clipboard

Support 'URL' and 'path.Path' instances as input to `fs.*` APIs

Open jwerle opened this issue 2 years ago • 3 comments

It will be a nice experience to support URL (and path.Path) instances to various fs.* APIs

import URL from 'socket:url'
import fs from 'socket:fs/promises'

const dirname = new URL('./directory', .import.meta.url)
const entries = fs.readdir(dirname)

The URL instance could be a fully qualified URL with the socket: protocol so this should be considered when converting these instances to path strings:

// this could be 'socket://com.company.application/pages/directory'
const dirname = new URL('./directory', .import.meta.url)

// which should become './pages/directory' internally for various `fs.*` APIs as the internal current working directory (.)
// will be the resources directory on desktop + ios (or the `files/` directory on Android)

jwerle avatar Sep 13 '23 15:09 jwerle

Hello, I am new to open source but would like to contribute. I'm not sure of the procedure, so any guidance is appreciated!

pmettaprasert avatar Sep 14 '23 00:09 pmettaprasert

@pmettaprasert Please feel free to open a PR and call out a reviewer to look at and merge your code.

lamiazar avatar Sep 14 '23 11:09 lamiazar

We have a contributing guide here https://github.com/socketsupply/socket/blob/master/CONTRIBUTING.md

chicoxyzzy avatar Sep 14 '23 12:09 chicoxyzzy