Update POSIX splitPathRe to allow control chars. Fixes #1230.
Use [\s\S] instead of . to match any char, including newlines.
This commit is contained in:
parent
04c9169892
commit
7f30f13543
@ -249,7 +249,7 @@ if (isWindows) {
|
|||||||
|
|
||||||
// Regex to split a filename into [*, dir, basename, ext]
|
// Regex to split a filename into [*, dir, basename, ext]
|
||||||
// posix version
|
// posix version
|
||||||
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
|
var splitPathRe = /^([\s\S]+\/(?!$)|\/)?((?:[\s\S]+?)?(\.[^.]*)?)$/;
|
||||||
|
|
||||||
// path.resolve([from ...], to)
|
// path.resolve([from ...], to)
|
||||||
// posix version
|
// posix version
|
||||||
|
@ -30,6 +30,14 @@ var f = __filename;
|
|||||||
|
|
||||||
assert.equal(path.basename(f), 'test-path.js');
|
assert.equal(path.basename(f), 'test-path.js');
|
||||||
assert.equal(path.basename(f, '.js'), 'test-path');
|
assert.equal(path.basename(f, '.js'), 'test-path');
|
||||||
|
|
||||||
|
// POSIX filenames may include control characters
|
||||||
|
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
|
||||||
|
if (!isWindows) {
|
||||||
|
var controlCharFilename = 'Icon' + String.fromCharCode(13);
|
||||||
|
assert.equal(path.basename('/a/b/' + controlCharFilename), controlCharFilename);
|
||||||
|
}
|
||||||
|
|
||||||
assert.equal(path.extname(f), '.js');
|
assert.equal(path.extname(f), '.js');
|
||||||
assert.equal(path.dirname(f).substr(-11), isWindows ? 'test\\simple' : 'test/simple');
|
assert.equal(path.dirname(f).substr(-11), isWindows ? 'test\\simple' : 'test/simple');
|
||||||
assert.equal(path.dirname('/a/b/'), '/a');
|
assert.equal(path.dirname('/a/b/'), '/a');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user