Can you help me to review my "mailto:"-parsing function ?
Since I'm trying to write less code, that is as simple as possible.
I'm not sure there if there is some bug or better solution.
var href = 'mailto:[email protected]?subject=My+Subject&body=My+Body';
function getMailto(s) {
var r = {};
var email = s.match(/mailto:([^\?]*)/);
email = email[1]?email[1]:false;
var subject = s.match(/subject=([^&]+)/);
subject = subject?subject[1].replace(/\+/g,' '):false;
var body = s.match(/body=([^&]+)/);
body = body?body[1].replace(/\+/g,' '):false;
if(email) {r['email'] = email;}
if(subject) {r['subject'] = subject;}
if(body) {r['body'] = body;}
return r;
}
console.log(getMailto(href));