-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.pathIssues and PRs related to the path subsystem.Issues and PRs related to the path subsystem.
Description
This test shows that name
and ext
are not taken into account when using path.format
without a base
.
The common usage this is preventing is this:
var src = path.parse(srcpath)
src.base = null
if(src.ext === '') src.ext = '.js'
src = path.format(src)
However this doesn't do anything.
var path = require('path')
var assert = require('assert')
// pulled from https://nodejs.org/api/path.html#path_path_format_pathobject
/* global describe, it */
describe('node path', function () {
it('should work as documented', function () {
assert.equal(path.format({
root: '/',
dir: '/home/user/dir',
base: 'file.txt',
ext: '.txt',
name: 'file'
}), '/home/user/dir/file.txt')
})
it('should not work if missing base', function () {
assert.notEqual(path.format({
root: '/',
dir: '/home/user/dir',
ext: '.txt',
name: 'file'
}), '/home/user/dir/file.txt')
})
it('should show ext and name are irrelevant', function () {
assert.equal(path.format({
root: '/',
dir: '/home/user/dir',
ext: '.txt',
name: 'file'
}), path.format({
root: '/',
dir: '/home/user/dir'
}))
})
})
https://github.com/nodejs/io.js/blob/master/lib/path.js#L584
I can write a pull request, if anyone else thinks this is a good idea.
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.pathIssues and PRs related to the path subsystem.Issues and PRs related to the path subsystem.