Skip to content

Commit

Permalink
Merge pull request #21 from ReptoxX/master
Browse files Browse the repository at this point in the history
Added german "From" to the regex list.
  • Loading branch information
baptistejamin authored Jul 15, 2024
2 parents d35cb14 + a3521c0 commit 0c0d715
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RegexList {
/^(.+\s<.+>\sschrieb:)$/m, // NAME <EMAIL> schrieb:
/^(.+\son.*at.*wrote:)$/m, // NAME on DATE wrote:
/^\s*(From\s?:.+\s?\n?\s*[\[|<].+[\]|>])/m, // "From: NAME <EMAIL>" OR "From : NAME <EMAIL>" OR "From : NAME<EMAIL>"(With support whitespace before start and before <)
/^\s*(Von\s?:.+\s?\n?\s*[\[|<].+[\]|>])/m, // "Von: NAME <EMAIL>" OR "Von : NAME <EMAIL>" OR "Von : NAME<EMAIL>"(With support whitespace before start and before <)
/^\s*(De\s?:.+\s?\n?\s*(\[|<).+(\]|>))/m, // "De: NAME <EMAIL>" OR "De : NAME <EMAIL>" OR "De : NAME<EMAIL>" (With support whitespace before start and before <)
/^\s*(Van\s?:.+\s?\n?\s*(\[|<).+(\]|>))/m, // "Van: NAME <EMAIL>" OR "Van : NAME <EMAIL>" OR "Van : NAME<EMAIL>" (With support whitespace before start and before <)
/^\s*(Da\s?:.+\s?\n?\s*(\[|<).+(\]|>))/m, // "Da: NAME <EMAIL>" OR "Da : NAME <EMAIL>" OR "Da : NAME<EMAIL>" (With support whitespace before start and before <)
Expand Down Expand Up @@ -61,4 +62,4 @@ class RegexList {
}
}

module.exports = new RegexList();
module.exports = new RegexList();
12 changes: 12 additions & 0 deletions test/fixtures/email_german_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus.
Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante.
Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum.
Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna,
et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh.

Von: John Doe <service@example.de>
Gesendet: Donnerstag, 23. März 2023 17:11
An: John Doe <service@example.de>
Betreff: AW: Hi there!

Hi there!
13 changes: 12 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ exports.test_email_german = function(test) {
test.done();
};

exports.test_email_german_2 = function(test) {
let email = get_email("email_german_2");

let fragments = email.getFragments();

test.equal(COMMON_FIRST_FRAGMENT, fragments[0].toString().trim());

test.done();
};

exports.test_email_gmail_no = function(test) {
let email = get_email("email_norwegian_gmail");

Expand Down Expand Up @@ -492,4 +502,5 @@ exports.test_email_original_message_2 = function(test) {
test.equal(2, fragments.length);

test.done();
}
}

0 comments on commit 0c0d715

Please sign in to comment.