Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

path.parse need #6976

Closed
litmit opened this issue Jan 26, 2014 · 3 comments
Closed

path.parse need #6976

litmit opened this issue Jan 26, 2014 · 3 comments

Comments

@litmit
Copy link

litmit commented Jan 26, 2014

When working with filenames its often need to split path to separate components simultaneously:

var dir = path.dirname(f);
var base = path.basename(f);
var ext= path.extname(f);

Internally all this functions uses universal parser splitPath that each time return all components of path. Moreover this parser returns the drive piece of path on Windows, but there is not any public API to achieve it.

It is possible to introduce new function in path module path.parse(f)?
path.parse must return object with next properties:

  • root - drive or UNC prefix (Windows specific)
  • dir directory name of a path (=== path.dirname() )
  • base last portion of a path (=== path.basename() )
  • ext extension (=== path.extname() )
  • name basename without extension and dot

Also, for completness, need the function path.format(pathObj) which takes a parsed path object and return a formatted path string.

@roryrjb
Copy link

roryrjb commented Apr 8, 2014

@litmit I'm looking into this now, once I've refined it and done plenty of tests I'll do a pull request.

@chrisdickinson
Copy link

Closing as a duplicate of #1224. Moving the discussion there!

chrisdickinson pushed a commit to chrisdickinson/node that referenced this issue Nov 18, 2014
The parse() function splits a path and returns an object

with the different elements. The format() function is the

reverse of this and adds an objects corresponding path

elements to make up a string. nodejs#6976
chrisdickinson pushed a commit to chrisdickinson/node that referenced this issue Nov 20, 2014
The parse() function splits a path and returns an object
with the different elements. The format() function is the
reverse of this and adds an objects corresponding path
elements to make up a string. Fixes nodejs#6976.
chrisdickinson pushed a commit to chrisdickinson/node that referenced this issue Nov 20, 2014
The parse() function splits a path and returns an object
with the different elements. The format() function is the
reverse of this and adds an objects corresponding path
elements to make up a string. Fixes nodejs#6976.
chrisdickinson pushed a commit to chrisdickinson/node that referenced this issue Nov 20, 2014
The parse() function splits a path and returns an object
with the different elements. The format() function is the
reverse of this and adds an objects corresponding path
elements to make up a string. Fixes nodejs#6976.
chrisdickinson pushed a commit to chrisdickinson/node that referenced this issue Nov 20, 2014
The parse() function splits a path and returns an object
with the different elements. The format() function is the
reverse of this and adds an objects corresponding path
elements to make up a string. Fixes nodejs#6976.
chrisdickinson pushed a commit to chrisdickinson/node that referenced this issue Nov 20, 2014
The parse() function splits a path and returns an object
with the different elements. The format() function is the
reverse of this and adds an objects corresponding path
elements to make up a string. Fixes nodejs#6976.
chrisdickinson pushed a commit that referenced this issue Nov 21, 2014
The parse() function splits a path and returns an object
with the different elements. The format() function is the
reverse of this and adds an objects corresponding path
elements to make up a string. Fixes #6976.

Fixes: #6976
PR-URL: #8750
Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
@chrisdickinson
Copy link

Fixed in 2d17193.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants