Commit fc5f5f25 authored by Sebastian Pekarek's avatar Sebastian Pekarek
Browse files

\n -> \r\n

close #21
parent b02e05ad
......@@ -29,7 +29,7 @@ module.exports.formatDate = function formatDate(d, dateonly, floating) {
module.exports.escape = function escape(str) {
return str.replace(/[\\;,\n"]/g, function(match) {
if (match === '\n') {
if(match === '\n') {
return '\\n';
}
......
......@@ -212,7 +212,7 @@ var ICalAlarm = function(_data, event) {
*/
this.generate = function() {
var tools = require('./_tools.js'),
g = 'BEGIN:VALARM\n';
g = 'BEGIN:VALARM\r\n';
if(!data.type) {
throw 'No value for `type` in ICalAlarm given!';
......@@ -222,16 +222,16 @@ var ICalAlarm = function(_data, event) {
}
// ACTION
g += 'ACTION:' + data.type.toUpperCase() + '\n';
g += 'ACTION:' + data.type.toUpperCase() + '\r\n';
if(data.trigger instanceof Date) {
g += 'TRIGGER;VALUE=DATE-TIME:' + tools.formatDate(data.trigger) + '\n';
g += 'TRIGGER;VALUE=DATE-TIME:' + tools.formatDate(data.trigger) + '\r\n';
}
else if(data.trigger > 0) {
g += 'TRIGGER;RELATED=END:' + tools.duration(data.trigger) + '\n';
g += 'TRIGGER;RELATED=END:' + tools.duration(data.trigger) + '\r\n';
}
else {
g += 'TRIGGER:' + tools.duration(data.trigger) + '\n';
g += 'TRIGGER:' + tools.duration(data.trigger) + '\r\n';
}
// REPEAT
......@@ -239,7 +239,7 @@ var ICalAlarm = function(_data, event) {
throw 'No value for `interval` in ICalAlarm given, but required for `repeat`!';
}
if(data.repeat) {
g += 'REPEAT:' + data.repeat + '\n';
g += 'REPEAT:' + data.repeat + '\r\n';
}
// INTERVAL
......@@ -247,29 +247,29 @@ var ICalAlarm = function(_data, event) {
throw 'No value for `repeat` in ICalAlarm given, but required for `interval`!';
}
if(data.interval) {
g += 'DURATION:' + tools.duration(data.interval) + '\n';
g += 'DURATION:' + tools.duration(data.interval) + '\r\n';
}
// ATTACH
if(data.type === 'audio' && data.attach && data.attach.mime) {
g += 'ATTACH;FMTTYPE=' + data.attach.mime + ':' + data.attach.uri + '\n';
g += 'ATTACH;FMTTYPE=' + data.attach.mime + ':' + data.attach.uri + '\r\n';
}
else if(data.type === 'audio' && data.attach ) {
g += 'ATTACH;VALUE=URI:' + data.attach.uri + '\n';
g += 'ATTACH;VALUE=URI:' + data.attach.uri + '\r\n';
}
else if(data.type === 'audio') {
g += 'ATTACH;VALUE=URI:Basso\n';
g += 'ATTACH;VALUE=URI:Basso\r\n';
}
// DESCRIPTION
if(data.type === 'display' && data.description) {
g += 'DESCRIPTION:' + tools.escape(data.description) + '\n';
g += 'DESCRIPTION:' + tools.escape(data.description) + '\r\n';
}
else if(data.type === 'display') {
g += 'DESCRIPTION:' + tools.escape(event.summary()) + '\n';
g += 'DESCRIPTION:' + tools.escape(event.summary()) + '\r\n';
}
g += 'END:VALARM\n';
g += 'END:VALARM\r\n';
return g;
};
......
......@@ -208,7 +208,7 @@ var ICalAttendee = function(_data, event) {
g += ';CN="' + data.name + '"';
}
g += ':MAILTO:' + data.email + '\n';
g += ':MAILTO:' + data.email + '\r\n';
return g;
};
......
......@@ -16,18 +16,18 @@ var ICalCalendar = function(_data) {
var g = '';
// VCALENDAR and VERSION
g = 'BEGIN:VCALENDAR\nVERSION:2.0\n';
g = 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\n';
// PRODID
g += 'PRODID:-' + data.prodid + '\n';
g += 'PRODID:-' + data.prodid + '\r\n';
// NAME
if(data.name) {
g += 'X-WR-CALNAME:' + data.name + '\n';
g += 'X-WR-CALNAME:' + data.name + '\r\n';
}
if(data.timezone) {
g += 'X-WR-TIMEZONE:' + data.timezone + '\n';
g += 'X-WR-TIMEZONE:' + data.timezone + '\r\n';
}
// Events
......
......@@ -495,15 +495,15 @@ var ICalEvent = function(_data) {
}
// DATE & TIME
g += 'BEGIN:VEVENT\n';
g += 'UID:' + tools.formatDate(data.start) + '-' + data.id + '@' + calendar.domain() + '\n';
g += 'DTSTAMP:' + tools.formatDate(data.stamp) + '\n';
g += 'BEGIN:VEVENT\r\n';
g += 'UID:' + tools.formatDate(data.start) + '-' + data.id + '@' + calendar.domain() + '\r\n';
g += 'DTSTAMP:' + tools.formatDate(data.stamp) + '\r\n';
if(data.allDay) {
g += 'DTSTART;VALUE=DATE:' + tools.formatDate(data.start, true) + '\n';
g += 'DTEND;VALUE=DATE:' + tools.formatDate(data.end, true) + '\n';
g += 'DTSTART;VALUE=DATE:' + tools.formatDate(data.start, true) + '\r\n';
g += 'DTEND;VALUE=DATE:' + tools.formatDate(data.end, true) + '\r\n';
}else{
g += 'DTSTART:' + tools.formatDate(data.start, false, data.floating) + '\n';
g += 'DTEND:' + tools.formatDate(data.end, false, data.floating) + '\n';
g += 'DTSTART:' + tools.formatDate(data.start, false, data.floating) + '\r\n';
g += 'DTEND:' + tools.formatDate(data.end, false, data.floating) + '\r\n';
}
// REPEATING
......@@ -522,25 +522,25 @@ var ICalEvent = function(_data) {
g += ';UNTIL=' + tools.formatDate(data.repeating.until);
}
g += '\n';
g += '\r\n';
}
// SUMMARY
g += 'SUMMARY:' + tools.escape(data.summary) + '\n';
g += 'SUMMARY:' + tools.escape(data.summary) + '\r\n';
// LOCATION
if(data.location) {
g += 'LOCATION:' + tools.escape(data.location) + '\n';
g += 'LOCATION:' + tools.escape(data.location) + '\r\n';
}
// DESCRIPTION
if(data.description) {
g += 'DESCRIPTION:' + tools.escape(data.description ) + '\n';
g += 'DESCRIPTION:' + tools.escape(data.description ) + '\r\n';
}
// ORGANIZER
if(data.organizer) {
g += 'ORGANIZER;CN="' + tools.escape(data.organizer.name) + '":mailto:' + tools.escape(data.organizer.email) + '\n';
g += 'ORGANIZER;CN="' + tools.escape(data.organizer.name) + '":mailto:' + tools.escape(data.organizer.email) + '\r\n';
}
// ATTENDEES
......@@ -555,18 +555,18 @@ var ICalEvent = function(_data) {
// URL
if(data.url) {
g += 'URL;VALUE=URI:' + tools.escape(data.url) + '\n';
g += 'URL;VALUE=URI:' + tools.escape(data.url) + '\r\n';
}
// METHOD & STATUS
if(data.method) {
g += 'METHOD:' + data.method.toUpperCase() + '\n';
g += 'METHOD:' + data.method.toUpperCase() + '\r\n';
}
if(data.status) {
g += 'STATUS:' + data.status.toUpperCase() + '\n';
g += 'STATUS:' + data.status.toUpperCase() + '\r\n';
}
g += 'END:VEVENT\n';
g += 'END:VEVENT\r\n';
return g;
};
......
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131004T231500Z
SUMMARY:Simple Event
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131004T231500Z
SUMMARY:Simple Event
END:VEVENT
END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131004T231500Z
SUMMARY:Sample Event
LOCATION:localhost
DESCRIPTION:Lorem ipsum dolor sit amet\, consetetur sadipscing elitr\, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat\, sed diam voluptua.\nbeep boop
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131004T231500Z
SUMMARY:Sample Event
LOCATION:localhost
DESCRIPTION:Lorem ipsum dolor sit amet\, consetetur sadipscing elitr\, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat\, sed diam voluptua.\nbeep boop
END:VEVENT
END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART;VALUE=DATE:20131004
DTEND;VALUE=DATE:20131006
SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART;VALUE=DATE:20131004
DTEND;VALUE=DATE:20131006
SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-1@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=MONTHLY
SUMMARY:repeating by month
END:VEVENT
BEGIN:VEVENT
UID:20131004T223930Z-2@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=DAILY;COUNT=2
SUMMARY:repeating by day\, twice
END:VEVENT
BEGIN:VEVENT
UID:20131004T223930Z-3@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=WEEKLY;INTERVAL=3;UNTIL=20140101T000000Z
SUMMARY:repeating by 3 weeks\, until 2014
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-1@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=MONTHLY
SUMMARY:repeating by month
END:VEVENT
BEGIN:VEVENT
UID:20131004T223930Z-2@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=DAILY;COUNT=2
SUMMARY:repeating by day\, twice
END:VEVENT
BEGIN:VEVENT
UID:20131004T223930Z-3@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930Z
DTEND:20131006T231500Z
RRULE:FREQ=WEEKLY;INTERVAL=3;UNTIL=20140101T000000Z
SUMMARY:repeating by 3 weeks\, until 2014
END:VEVENT
END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-1@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930
DTEND:20131006T231500
SUMMARY:floating
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-1@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART:20131004T223930
DTEND:20131006T231500
SUMMARY:floating
END:VEVENT
END:VCALENDAR
\ No newline at end of file
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART;VALUE=DATE:20131004
DTEND;VALUE=DATE:20131006
SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;DELEGATED-FROM="matt@example.com";CN="John":MAILTO:john@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=DELEGATED;DELEGATED-TO="john@example.com";CN="Matt":MAILTO:matt@example.com
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT10M
REPEAT:2
DURATION:PT1M
DESCRIPTION:Sample Event
END:VALARM
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT1H
DESCRIPTION:I'm a reminder :)
END:VALARM
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//sebbo.net//ical-generator.tests//EN
BEGIN:VEVENT
UID:20131004T223930Z-123@sebbo.net
DTSTAMP:20131004T233453Z
DTSTART;VALUE=DATE:20131004
DTEND;VALUE=DATE:20131006
SUMMARY:Sample Event
ORGANIZER;CN="Sebastian Pekarek":mailto:mail@sebbo.net
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;DELEGATED-FROM="matt@example.com";CN="John":MAILTO:john@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=DELEGATED;DELEGATED-TO="john@example.com";CN="Matt":MAILTO:matt@example.com
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT10M
REPEAT:2
DURATION:PT1M
DESCRIPTION:Sample Event
END:VALARM
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT1H
DESCRIPTION:I'm a reminder :)
END:VALARM
URL;VALUE=URI:http://sebbo.net/
METHOD:ADD
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
\ No newline at end of file
......@@ -1594,16 +1594,16 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
trigger: 300
});
assert.ok(cal.toString().indexOf('\nATTACH;VALUE=URI:Basso') > -1);
assert.ok(cal.toString().indexOf('\r\nATTACH;VALUE=URI:Basso') > -1);
a.attach('https://example.com/beep.aud');
assert.ok(cal.toString().indexOf('\nATTACH;VALUE=URI:https://example.com/beep.aud') > -1);
assert.ok(cal.toString().indexOf('\r\nATTACH;VALUE=URI:https://example.com/beep.aud') > -1);
a.attach({
uri: 'https://example.com/beep.aud',
mime: 'audio/basic'
});
assert.ok(cal.toString().indexOf('\nATTACH;FMTTYPE=audio/basic:https://example.com/beep.aud') > -1);
assert.ok(cal.toString().indexOf('\r\nATTACH;FMTTYPE=audio/basic:https://example.com/beep.aud') > -1);
});
});
......@@ -1627,7 +1627,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
event.createAlarm({type: 'display', trigger: 300, description: 'Huibuh!'});
assert.ok(cal.toString().indexOf('\nDESCRIPTION:Huibuh') > -1);
assert.ok(cal.toString().indexOf('\r\nDESCRIPTION:Huibuh') > -1);
});
it('should fallback to event summary', function() {
......@@ -1639,7 +1639,7 @@ describe('ical-generator 0.2.x / ICalCalendar', function() {
});
event.createAlarm({type: 'display', trigger: 300});
assert.ok(cal.toString().indexOf('\nDESCRIPTION:Example Event') > -1);
assert.ok(cal.toString().indexOf('\r\nDESCRIPTION:Example Event') > -1);
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment