emailjs-imap-handler
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "emailjs-imap-handler", | ||
"main": "src/emailjs-imap-handler.js", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"homepage": "https://github.com/emailjs/emailjs-imap-handler", | ||
@@ -6,0 +6,0 @@ "author": "Andris Reinman <andris@kreata.ee>", |
@@ -41,6 +41,6 @@ // Copyright (c) 2013 Andris Reinman | ||
resp = (response.tag || '') + (response.command ? ' ' + response.command : ''), | ||
val, lastType, | ||
val, needsSpace = true, | ||
walk = function(node) { | ||
if (lastType === 'LITERAL' || (['(', '<', '['].indexOf(resp.substr(-1)) < 0 && resp.length)) { | ||
if (resp.length > 0 && needsSpace) { | ||
resp += ' '; | ||
@@ -50,3 +50,3 @@ } | ||
if (Array.isArray(node)) { | ||
lastType = 'LIST'; | ||
needsSpace = false; | ||
resp += '('; | ||
@@ -56,2 +56,4 @@ node.forEach(walk); | ||
return; | ||
} else { | ||
needsSpace = true; | ||
} | ||
@@ -78,4 +80,2 @@ | ||
lastType = node.type; | ||
if (isLogging && node.sensitive) { | ||
@@ -128,2 +128,3 @@ resp += '"(* value hidden *)"'; | ||
if (node.section) { | ||
needsSpace = false; | ||
resp += '['; | ||
@@ -130,0 +131,0 @@ node.section.forEach(walk); |
@@ -18,3 +18,3 @@ (function(root, factory) { | ||
it('should compile correctly', function() { | ||
var command = '* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL) ("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL) ("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))', | ||
var command = '* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE BODY.PEEK[HEADER.FIELDS (REFERENCES, LIST-ID)] (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL) ("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL) ("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))', | ||
parsed = imapHandler.parser(command, { | ||
@@ -21,0 +21,0 @@ allowUntagged: true |
200033
4040