readline: check for null input in question()

question() checks for objects passed as the recently added options
argument. This commit improves that logic to also check for null.

PR-URL: https://github.com/nodejs/node/pull/37089
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
cjihrig authored and Michaël Zasso committed 2021-02-02 10:47:41 +01:00
1 parent fe9f4fdba5
commit 3d64d2b5ef
1 file changed
+2 -2
+2 -2
View File
@@ -364,7 +364,7 @@ Interface.prototype.prompt = function(preserveCursor) {
Interface.prototype.question = function(query, options, cb) {
cb = typeof options === 'function' ? options : cb;
options = typeof options === 'object' ? options : {};
options = typeof options === 'object' && options !== null ? options : {};
if (options.signal) {
options.signal.addEventListener('abort', () => {
@@ -385,7 +385,7 @@ Interface.prototype.question = function(query, options, cb) {
};
Interface.prototype.question[promisify.custom] = function(query, options) {
options = typeof options === 'object' ? options : {};
options = typeof options === 'object' && options !== null ? options : {};
return new Promise((resolve, reject) => {
this.question(query, options, resolve);