email-forward-parser 1.0.18 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/parser.js +15 -8
- package/package.json +1 -1
package/lib/parser.js
CHANGED
|
@@ -130,7 +130,7 @@ var REGEXES = {
|
|
|
130
130
|
],
|
|
131
131
|
|
|
132
132
|
original_subject : [
|
|
133
|
-
|
|
133
|
+
/^\*?Subject\s?:\*?(.+)/im, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en)
|
|
134
134
|
/^Předmět\s?:(.+)/im, // Apple Mail (cs), New Outlook 2019 (cs), Thunderbird (cs)
|
|
135
135
|
/^Emne\s?:(.+)/im, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
136
136
|
/^Betreff\s?:(.+)/im, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
@@ -172,7 +172,7 @@ var REGEXES = {
|
|
|
172
172
|
],
|
|
173
173
|
|
|
174
174
|
original_from : [
|
|
175
|
-
/^(
|
|
175
|
+
/^(\*?\s*From\s?:\*?(.+))$/m, // Apple Mail (en), Outlook Live / 365 (all locales), New Outlook 2019 (en), Thunderbird (da, en), Missive (en)
|
|
176
176
|
/^(\s*Od\s?:(.+))$/m, // Apple Mail (cs, pl, sk), Gmail (cs, pl, sk), New Outlook 2019 (cs, pl, sk), Thunderbird (cs, sk)
|
|
177
177
|
/^(\s*Fra\s?:(.+))$/m, // Apple Mail (da, no), Gmail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
178
178
|
/^(\s*Von\s?:(.+))$/m, // Apple Mail (de), Gmail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
@@ -215,7 +215,7 @@ var REGEXES = {
|
|
|
215
215
|
],
|
|
216
216
|
|
|
217
217
|
original_to : [
|
|
218
|
-
|
|
218
|
+
/^\*?\s*To\s?:\*?(.+)$/m, // Apple Mail (en), Gmail (all locales), Outlook Live / 365 (all locales), Thunderbird (da, en), Missive (en)
|
|
219
219
|
/^\s*Komu\s?:(.+)$/m, // Apple Mail (cs), New Outlook 2019 (cs, sk), Thunderbird (cs)
|
|
220
220
|
/^\s*Til\s?:(.+)$/m, // Apple Mail (da, no), New Outlook 2019 (da), Thunderbird (no)
|
|
221
221
|
/^\s*An\s?:(.+)$/m, // Apple Mail (de), New Outlook 2019 (de), Thunderbird (de)
|
|
@@ -278,7 +278,7 @@ var REGEXES = {
|
|
|
278
278
|
],
|
|
279
279
|
|
|
280
280
|
original_cc : [
|
|
281
|
-
|
|
281
|
+
/^\*?\s*Cc\s?:\*?(.+)$/m, // Apple Mail (en, da, es, fr, hr, it, pt, pt-br, ro, sk), Gmail (all locales), Outlook Live / 365 (all locales), New Outlook 2019 (da, de, en, fr, it, pt-br), Missive (en)
|
|
282
282
|
/^\s*CC\s?:(.+)$/m, // New Outlook 2019 (es, nl, pt), Thunderbird (da, en, es, fi, hr, hu, it, nl, no, pt, pt-br, ro, tr, uk)
|
|
283
283
|
/^\s*Kopie\s?:(.+)$/m, // Apple Mail (cs, de, nl), New Outlook 2019 (cs), Thunderbird (cs)
|
|
284
284
|
/^\s*Kopio\s?:(.+)$/m, // Apple Mail (fi), New Outlook 2019 (es)
|
|
@@ -321,7 +321,7 @@ var REGEXES = {
|
|
|
321
321
|
/^\s*Dată\s?:(.+)$/m, // Apple Mail (ro), Thunderbird (ro)
|
|
322
322
|
/^\s*Дата\s?:(.+)$/m, // Apple Mail (ru, uk), New Outlook 2019 (ru), Thunderbird (ru, uk)
|
|
323
323
|
/^\s*Tarih\s?:(.+)$/m, // Apple Mail (tr), Thunderbird (tr)
|
|
324
|
-
|
|
324
|
+
/^\*?\s*Sent\s?:\*?(.+)$/m, // Outlook Live / 365 (all locales)
|
|
325
325
|
/^\s*Päiväys\s?:(.+)$/m // Thunderbird (fi)
|
|
326
326
|
],
|
|
327
327
|
|
|
@@ -354,7 +354,8 @@ var REGEXES = {
|
|
|
354
354
|
/^\"(.+?)\"\s?\n?\s*[\[|<](.+?)[\]|>]/, // ""Walter Sheltan" <walter.sheltan@acme.com>" or ""Walter Sheltan" [walter.sheltan@acme.com]" or ""walter.sheltan@acme.com" <walter.sheltan@acme.com>"
|
|
355
355
|
/^([^,;]+?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "Walter Sheltan <walter.sheltan@acme.com>" or "Walter Sheltan [walter.sheltan@acme.com]" or "walter.sheltan@acme.com <walter.sheltan@acme.com>"
|
|
356
356
|
/^(.?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "<walter.sheltan@acme.com>"
|
|
357
|
-
/^([^\s@]+@[^\s@]+\.[^\s@,]+)
|
|
357
|
+
/^([^\s@]+@[^\s@]+\.[^\s@,]+)/, // "walter.sheltan@acme.com"
|
|
358
|
+
/^([^;].+?)\s?\n?\s*[\[|<](.+?)[\]|>]/, // "Walter, Sheltan <walter.sheltan@acme.com>" or "Walter, Sheltan [walter.sheltan@acme.com]"
|
|
358
359
|
]
|
|
359
360
|
};
|
|
360
361
|
|
|
@@ -425,11 +426,12 @@ class Parser {
|
|
|
425
426
|
// attempt it. The `forwarded` boolean gives the confirmation that the \
|
|
426
427
|
// email was indeed forwarded (detected from the Subject part)
|
|
427
428
|
if (forwarded === true) {
|
|
428
|
-
// Second method: split via the Form part (New Outlook 2019
|
|
429
|
+
// Second method: split via the Form part (New Outlook 2019, \
|
|
430
|
+
// Outlook Live / 365)
|
|
429
431
|
_match = loopRegexes(this.__regexes.original_from, _body, "split");
|
|
430
432
|
|
|
431
433
|
if (_match && _match.length > 3) {
|
|
432
|
-
// The From has been detached by `split
|
|
434
|
+
// The From has been detached by the `split` operation, attach it back
|
|
433
435
|
var _email = _match[1] + _match[_match.length - 1];
|
|
434
436
|
|
|
435
437
|
return {
|
|
@@ -570,6 +572,11 @@ class Parser {
|
|
|
570
572
|
return _author;
|
|
571
573
|
}
|
|
572
574
|
|
|
575
|
+
// Multiple authors found?
|
|
576
|
+
if (Array.isArray(_author) && _author[0].address) {
|
|
577
|
+
return _author[0];
|
|
578
|
+
}
|
|
579
|
+
|
|
573
580
|
// Second method: extract the author via the separator (Outlook 2019)
|
|
574
581
|
var _match = loopRegexes(this.__regexes.separator_with_information, body);
|
|
575
582
|
|