doc,test: empty strings in path module
authorSakthipriyan Vairamani <thechargingvolcano@gmail.com>
Sun, 5 Jul 2015 15:08:16 +0000 (15:08 +0000)
committerRich Trott <rtrott@gmail.com>
Tue, 14 Jul 2015 15:56:50 +0000 (08:56 -0700)
commit65963ec26f8bcb9ef287aa7ddd40e8ecc734d991
tree85791da6115f62b6112ce8693d72886223390890
parent5acad6b16399cee476851a71f78b1c488bd46643
doc,test: empty strings in path module

The path module's `join, normalize, isAbsolute, relative and resolve`
functions return/use the current directory if they are passed zero
length strings.

    > process.version
    'v2.3.4-pre'
    > path.win32.join('')
    '.'
    > path.posix.join('')
    '.'
    > path.win32.normalize('')
    '.'
    > path.posix.normalize('')
    '.'
    > path.win32.isAbsolute('')
    false
    > path.posix.isAbsolute('')
    false
    > path.win32.relative('', '')
    ''
    > path.posix.relative('', '')
    ''
    > path.win32relative('.', '')
    ''
    > path.posix.relative('.', '')
    ''
    > path.posix.resolve('')
    '/home/thefourtheye/Desktop'
    > path.win32.resolve('')
    '\\home\\thefourtheye\\Desktop'

Since empty paths are not valid in any of the operating systems people
normally use, this behaviour might be a surprise to the users. This
commit introduces "Notes" about this, wherever applicable in `path`'s
documentation.

The tests makes sure that the behaviour is intact between
commits.

PR-URL: https://github.com/nodejs/io.js/pull/2106
Reviewed-By: Rich Trott <rtrott@gmail.com>
doc/api/path.markdown
test/parallel/test-path-zero-length-strings.js [new file with mode: 0644]