fix(mailto): Correct mailto handling when link has & instead of first ?

This commit is contained in:
Ben Gotow 2015-09-30 14:28:35 -07:00
parent 728d99e5e0
commit 48ed1a98f1
2 changed files with 7 additions and 1 deletions

View file

@ -852,6 +852,7 @@ describe "DraftStore", ->
'mailto:?subject=%52z2a', # passes uriDecode
'mailto:?subject=Martha Stewart',
'mailto:?subject=Martha Stewart&cc=cc@nylas.com',
'mailto:bengotow@gmail.com&subject=Martha Stewart&cc=cc@nylas.com',
'mailto:bengotow@gmail.com?subject=Martha%20Stewart&cc=cc@nylas.com&bcc=bcc@nylas.com',
'mailto:bengotow@gmail.com?subject=Martha%20Stewart&cc=cc@nylas.com&bcc=Ben <bcc@nylas.com>',
'mailto:Ben Gotow <bengotow@gmail.com>,Shawn <shawn@nylas.com>?subject=Yes this is really valid'
@ -879,6 +880,11 @@ describe "DraftStore", ->
cc: [new Contact(name: 'cc@nylas.com', email: 'cc@nylas.com')],
subject: 'Martha Stewart'
),
new Message(
to: [new Contact(name: 'bengotow@gmail.com', email: 'bengotow@gmail.com')],
cc: [new Contact(name: 'cc@nylas.com', email: 'cc@nylas.com')],
subject: 'Martha Stewart'
),
new Message(
to: [new Contact(name: 'bengotow@gmail.com', email: 'bengotow@gmail.com')],
cc: [new Contact(name: 'cc@nylas.com', email: 'cc@nylas.com')],

View file

@ -418,7 +418,7 @@ class DraftStore
try
urlString = decodeURI(urlString)
[whole, to, query] = /mailto:[//]?([^\?]*)[\?]?(.*)/.exec(urlString)
[whole, to, query] = /mailto:[//]?([^\?\&]*)[\?\&]?(.*)/.exec(urlString)
query = require('querystring').parse(query)
query.to = to