Improved signatureIdentify().
This commit is contained in:
parent
6584090bad
commit
16232826cf
2 changed files with 10 additions and 5 deletions
|
@ -241,7 +241,7 @@ class App.Utils
|
||||||
|
|
||||||
cleanup = (str) ->
|
cleanup = (str) ->
|
||||||
if str.match(/(<|>|&)/)
|
if str.match(/(<|>|&)/)
|
||||||
str = str.replace(/(<|>|&).+?$/, '').trim()
|
str = str.replace(/(.+?)(<|>|&).+?$/, "$1").trim()
|
||||||
str
|
str
|
||||||
|
|
||||||
# search for signature seperator "--\n"
|
# search for signature seperator "--\n"
|
||||||
|
@ -424,10 +424,10 @@ class App.Utils
|
||||||
# get first marker
|
# get first marker
|
||||||
markers = _.sortBy(markers, 'lineCount')
|
markers = _.sortBy(markers, 'lineCount')
|
||||||
if markers[0].type is 'seperator'
|
if markers[0].type is 'seperator'
|
||||||
regex = new RegExp( "\>(\s{0,10}#{quote(markers[0].line)})\s{0,10}\<" )
|
regex = new RegExp( "\>(\s{0,10}#{quote(App.Utils.htmlEscape(markers[0].line))})\s{0,10}\<" )
|
||||||
message.replace( regex, ">#{markerTemplate}\$1<" )
|
message.replace( regex, ">#{markerTemplate}\$1<" )
|
||||||
else
|
else
|
||||||
regex = new RegExp( "\>(\s{0,10}#{quote(markers[0].line)})" )
|
regex = new RegExp( "\>(\s{0,10}#{quote(App.Utils.htmlEscape(markers[0].line))})" )
|
||||||
message.replace( regex, ">#{markerTemplate}\$1" )
|
message.replace( regex, ">#{markerTemplate}\$1" )
|
||||||
|
|
||||||
# textReplaced = App.Utils.replaceTags( template, { user: { firstname: 'Bob', lastname: 'Smith' } } )
|
# textReplaced = App.Utils.replaceTags( template, { user: { firstname: 'Bob', lastname: 'Smith' } } )
|
||||||
|
|
|
@ -630,8 +630,13 @@ test("identify signature", function() {
|
||||||
result = App.Utils.signatureIdentify(message, true)
|
result = App.Utils.signatureIdentify(message, true)
|
||||||
equal(result, should)
|
equal(result, should)
|
||||||
|
|
||||||
message = "<div>Von: \"Johannes Nickel via Znuny Projects\" <<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>></div><div>An: \"Lisa Smith\" <<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>></div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
|
message = "<div>Von: "Johannes Nickel via Znuny Projects" <<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>></div><div>An: \"Lisa Smith\" <<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>></div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
|
||||||
should = "<div><span class=\"js-signatureMarker\"></span>Von: \"Johannes Nickel via Znuny Projects\" <<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>></div><div>An: \"Lisa Smith\" <<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>></div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
|
should = "<div><span class=\"js-signatureMarker\"></span>Von: "Johannes Nickel via Znuny Projects" <<a href=\"mailto:projects@znuny.inc\" title=\"mailto:projects@znuny.inc\">projects@znuny.inc</a>></div><div>An: \"Lisa Smith\" <<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>></div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
|
||||||
|
result = App.Utils.signatureIdentify(message, true)
|
||||||
|
equal(result, should)
|
||||||
|
|
||||||
|
message = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div>> On 07 Oct 2015, at 11:55, Johannes Smith <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>>> wrote:</div><div>></div><div>> Hi,</div><div>></div><div>> OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
|
||||||
|
should = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div><span class=\"js-signatureMarker\"></span>> On 07 Oct 2015, at 11:55, Johannes Smith <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> <<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>>> wrote:</div><div>></div><div>> Hi,</div><div>></div><div>> OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
|
||||||
result = App.Utils.signatureIdentify(message, true)
|
result = App.Utils.signatureIdentify(message, true)
|
||||||
equal(result, should)
|
equal(result, should)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue