Skip to content

Commit

Permalink
readline: check for null input in question()
Browse files Browse the repository at this point in the history
question() checks for objects passed as the recently added options
argument. This commit improves that logic to also check for null.

PR-URL: #37089
Reviewed-By: Zijian Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
  • Loading branch information
cjihrig authored and targos committed Feb 2, 2021
1 parent fe9f4fd commit 3d64d2b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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);
Expand Down

0 comments on commit 3d64d2b

Please sign in to comment.