Permalink
Browse files

os, bugfix: os.userInfo().homedir include a terminal character.

  • Loading branch information...
xicilion committed Jun 5, 2018
1 parent 917fac2 commit 4780cedb0269f050984f4804e923030d5938a38f
Showing with 2 additions and 1 deletion.
  1. +1 −1 fibjs/src/os/os_win.cpp
  2. +1 −0 test/os_test.js
View
@@ -673,7 +673,7 @@ result_t os_base::userInfo(v8::Local<v8::Object> options, v8::Local<v8::Object>&
}
}
CloseHandle(token);
homedir = utf16to8String(path, (int32_t)buffersize);
homedir = utf16to8String(path, (int32_t)buffersize - 1);
path_base::normalize(homedir, homedir);
if (homedir.length() > 1 && isPathSlash(homedir[homedir.length() - 1]))
View
@@ -195,6 +195,7 @@ describe('os', () => {
assert.strictEqual(userInfo.shell, userInfoBuffer.shell.toString('utf8'));
}
assert.equal(os.homedir(), userInfo.homedir);
assert.isString(userInfo.username);
assert.ok(userInfo.homedir.includes(path.sep));
assert.strictEqual(userInfo.username, userInfoBuffer.username.toString('utf8'));

0 comments on commit 4780ced

Please sign in to comment.