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 <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>
  • Loading branch information
cjihrig authored and Lxxyx committed Jan 29, 2021
1 parent 1b222f9 commit b02030d
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 @@ -372,7 +372,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 @@ -393,7 +393,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 b02030d

Please sign in to comment.