diff options
-rw-r--r-- | doc/api/path.markdown | 16 | ||||
-rw-r--r-- | lib/path.js | 2 | ||||
-rw-r--r-- | test/simple/test-path.js | 8 |
3 files changed, 26 insertions, 0 deletions
diff --git a/doc/api/path.markdown b/doc/api/path.markdown index 5e0957d257..d178b53f1f 100644 --- a/doc/api/path.markdown +++ b/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'] diff --git a/lib/path.js b/lib/path.js index 148b2af9a1..ad8fd8d787 100644 --- a/lib/path.js +++ b/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 = '/'; } diff --git a/test/simple/test-path.js b/test/simple/test-path.js index caf86aa465..a5c7372d7d 100644 --- a/test/simple/test-path.js +++ b/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, '/'); +} |