On Windows, path.isAbsolute() returns an empty string on failed cases.
This forces the return value to always be boolean.
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Internal function trim(arr). 2nd parameter of slice() should be slice's
end index (not included). Because of function normalize() (called before
trim()), "start" is always zero so the bug -for now- has no effect, but
its a bug waiting to happen.
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Performance gains are ~4x (~1.5us), but still much slower than a naive
approach. There is some duplicate work done between join(), normalize()
and normalizeArray() so additional optimizations are possible.
Note that this only improves the POSIX implementation.
Thanks to @isaacs and @othiym23 for helping with this optimization.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
An absolute path will always open the same location regardless of your
current working directory. For posix, this just means path.charAt(0) ===
'/', but on Windows it's a little more complicated.
Fixes joyent/node#5299.
Fixes #5071, #5073.
* Normalize capitalization of drive letter
* Fix `exit()` typo in failure path
* Ignore symlink tests (Windows) if not elevated
The `test_relative_input_cwd()` test was failing on Windows when
`skipSymlinks` was `true`. So we won't run it if `skipSymlinks` is
`true`.
When it failed, the unhandled error caused Node to die before
having a chance to clean up, which resulted in two files missing
in subsequent unit tests:
* `test/fixtures/nested-index/one/hello.js`
* `test/fixtures/nested-index/one/index.js`
We should probably find a way to isolate this test from the other
test (`simple/test-module-loading`) that was failing when this test
poluted the disk state.
lib/path.js:
- throws a TypeError on the filter if the argument is not a string.
test/simple/test-path.js:
- removed the test to check if non-string types are filtered.
- added a test to check if path.join throws TypeError on arguments that
are not strings.
`path.exists*` functions show a deprecation warning and call functions
from `fs`. They should be removed later.
test: fix references to `path.exists*` in tests
test fs: add test for `fs.exists` and `fs.existsSync`
doc: reflect moving `path.exists*` to `fs`
lib/path.js routines normalizeArray() and resolve() have for loops that
count down from end of an array. The loop indexes are initialized using
"array.length" rather than "array.length-1". The initial array element
accessed is always beyond the end of array and the value is 'undefined'.
Strangely, code exists that acts to ignore undefined values so that the
typos are unnoticeable.
Existing tests emit no errors either before or after changing to "length-1".
Tests _do_ start failing at "length-2". (Actually it is node that starts
to fail at "length-2" - that's a valid enough test...)