diff --git a/docs/src/misc.rst b/docs/src/misc.rst index 3d1b11ca..10c349e9 100644 --- a/docs/src/misc.rst +++ b/docs/src/misc.rst @@ -207,6 +207,10 @@ API Gets the current working directory. + .. versionchanged:: 1.1.0 + + On Unix the path no longer ends in a slash. + .. c:function:: int uv_chdir(const char* dir) Changes the current working directory. diff --git a/src/unix/core.c b/src/unix/core.c index c08040e5..44995b22 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -635,6 +635,11 @@ int uv_cwd(char* buffer, size_t* size) { return -errno; *size = strlen(buffer); + if (*size > 1 && buffer[*size - 1] == '/') { + buffer[*size-1] = '\0'; + (*size)--; + } + return 0; }