From 2029bd9da3bca3131c6d233fa72cb5ea908bdc79 Mon Sep 17 00:00:00 2001 From: Brian White Date: Thu, 3 Jan 2013 23:43:23 -0500 Subject: [PATCH] default to all fields for undefined `headers.fields` for fetch() --- README.md | 4 ++-- lib/imap.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d17e968..68e6bdb 100644 --- a/README.md +++ b/README.md @@ -564,13 +564,13 @@ Valid `options` are: * **headers** - < _mixed_ > - An _array_ of specific headers to retrieve, _boolean_ true to fetch all headers, or an _object_ of the form (**Default:** (no headers)): - * **fields** - < _mixed_ > - An _array_ of specific headers to retrieve or _boolean_ true to fetch all headers. + * **fields** - < _mixed_ > - An _array_ of specific headers to retrieve or _boolean_ true to fetch all headers. **Default:** (all headers) * **parse** - < _boolean_ > - Parse headers? **Default:** true * **headersNot** - < _mixed_ > - An _array_ of specific headers to exclude or an _object_ of the form (**Default:** (no headers)): - * **fields** - < _mixed_ > - An _array_ of specific headers to exclude. + * **fields** - < _mixed_ > - An _array_ of specific headers to exclude. **Default:** (all headers) * **parse** - < _boolean_ > - Parse headers? **Default:** true diff --git a/lib/imap.js b/lib/imap.js index fa846c1..dd18f21 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -996,6 +996,8 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { if (Array.isArray(wp.headers)) headers = wp.headers; else if (typeof wp.headers === 'object') { + if (wp.headers.fields === undefined) + wp.headers.fields = true; if (!Array.isArray(wp.headers.fields) && typeof wp.headers.fields !== 'string' && wp.headers.fields !== true) @@ -1026,6 +1028,8 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { if (Array.isArray(wp.headersNot)) headers = wp.headersNot; else if (typeof wp.headersNot === 'object') { + if (wp.headersNot.fields === undefined) + wp.headersNot.fields = true; if (!Array.isArray(wp.headersNot.fields) && typeof wp.headersNot.fields !== 'string' && wp.headersNot.fields !== true)