fix mailto query string to allow 'Subject' as a valid key

Summary: Allow 'Subject=' and 'SUBJECT=' as valid keys for 'mailto:' links.

Test Plan: Didn't break any tests, so I added a few.

Reviewers: bengotow

Reviewed By: bengotow

Maniphest Tasks: T2415

Differential Revision: https://phab.nylas.com/D1865
This commit is contained in:
dillon 2015-08-11 11:22:35 -07:00
parent 8107be6ec4
commit e6f1b14a6a
2 changed files with 19 additions and 0 deletions

View file

@ -673,6 +673,22 @@ describe "DraftStore", ->
DraftStore._onHandleMailtoLink('mailto:bengotow@gmail.com')
expect(received.body.indexOf("Edited by TestExtension!")).toBe(0)
it "should be case-insensitive towards subject keys", ->
received = null
spyOn(DraftStore, '_finalizeAndPersistNewMessage').andCallFake (draft) ->
received = draft
Promise.resolve({draftLocalId: 123})
expected = "EmailSubjectLOLOL"
DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?subject=' + expected)
expect(received.subject).toBe(expected)
DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?Subject=' + expected)
expect(received.subject).toBe(expected)
DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?SUBJECT=' + expected)
expect(received.subject).toBe(expected)
it "should correctly instantiate drafts for a wide range of mailto URLs", ->
received = null
spyOn(DatabaseStore, 'persistModel').andCallFake (draft) ->

View file

@ -365,6 +365,9 @@ class DraftStore
query = require('querystring').parse(query)
query.to = to
for key, val of query
query[key.toLowerCase()] = val
draft = new Message
body: query.body || ''
subject: query.subject || '',