Browse Source

path: add path.sep to get the path separator.

v0.9.1-release
Yi, EungJun 13 years ago
committed by Ben Noordhuis
parent
commit
4bd54dad33
  1. 16
      doc/api/path.markdown
  2. 2
      lib/path.js
  3. 8
      test/simple/test-path.js

16
doc/api/path.markdown

@ -138,3 +138,19 @@ an empty string. Examples:
path.extname('index')
// returns
''
## path.sep
The platform-specific file separator. `'\\'` or `'/'`.
An example on linux:
'foo/bar/baz'.split(path.sep)
// returns
['foo', 'bar', 'baz']
An example on windows:
'foo\\bar\\baz'.split(path.sep)
// returns
['foo', 'bar', 'baz']

2
lib/path.js

@ -258,6 +258,7 @@ if (isWindows) {
return outputParts.join('\\');
};
exports.sep = '\\';
} else /* posix */ {
@ -373,6 +374,7 @@ if (isWindows) {
return outputParts.join('/');
};
exports.sep = '/';
}

8
test/simple/test-path.js

@ -273,3 +273,11 @@ relativeTests.forEach(function(test) {
});
assert.equal(failures.length, 0, failures.join(''));
// path.sep tests
if (isWindows) {
// windows
assert.equal(path.sep, '\\');
} else {
// posix
assert.equal(path.sep, '/');
}

Loading…
Cancel
Save