This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
path.parse need #6976
Closed
Description
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.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
roryrjb commentedon 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 commentedon Nov 18, 2014
Closing as a duplicate of #1224. Moving the discussion there!
path: added parse() and format() functions
path: added parse() and format() functions
path: added parse() and format() functions
path: added parse() and format() functions
path: added parse() and format() functions
path: added parse() and format() functions
path: added parse() and format() functions
chrisdickinson commentedon Nov 21, 2014
Fixed in 2d17193.