Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

Commit

Permalink
Automatically format CAL-ADDRESS with mailto: prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
james-emerton committed Oct 5, 2014
1 parent 744ceff commit ef006fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/types.js
Expand Up @@ -50,7 +50,12 @@ var _types = {
}
},
'CAL-ADDRESS': {
format: function(value) { return value.toString(); }
format: function(value) {
var v = value.toString();
if(v.lastIndexOf("mailto:") != 0)
v = "mailto:"+v;
return v;
}
},
'DATE': {
format: function(value) {
Expand Down
7 changes: 7 additions & 0 deletions spec/types-spec.js
Expand Up @@ -60,6 +60,13 @@ describe('iCalendar type formatters and parsers', function() {

});

it('automatically prepends mailto: for CAL-ADDRESS properties', function() {
expect(icalendar.format_value('CAL-ADDRESS', 'bob@example.com'))
.toEqual('mailto:bob@example.com');
expect(icalendar.format_value('CAL-ADDRESS', 'mailto:bob@example.com'))
.toEqual('mailto:bob@example.com');
});

it('value parsers', function() {
assert.equal('\u0000\u0001\u0002\u0004\u0005\u0006',
icalendar.parse_value('BINARY', 'AAECBAUG'));
Expand Down

1 comment on commit ef006fd

@comster
Copy link

@comster comster commented on ef006fd Jan 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this isn't right, but the form of username:mailto:emailaddress won't work anymore

var properties = {
'CN' : 'Some guy:mailto:someguy@gmail.com'
}
event.addProperty('ATTENDEE', '', properties);

Please sign in to comment.