Skip to content

path: Throwing error on zero length strings

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

> process.version
'v2.3.4-pre'
> path.join('')
'.'
> 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('.', '')
''

But that is unintuitive. This PR throws an error if any of the parameters to those functions are zero length strings.

Merge request reports

Loading