Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/vobject/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ module.exports = function(name, value, parameters) {

var line = ics.join('');

// Only the first line should be trimmed to 75
// every other line should be trimmed to 74
var lines = [];
for (var i = 0; i < Math.ceil(line.length / 75); i++) {
var part = line.substring(i * 75, Math.min((i + 1) * 75, line.length));
var lineCount = Math.ceil(Math.max(0, line.length - 75) / 74) + 1;
for (var i = 0, o = 0; i < lineCount; i++) {
var offset = 74;
if (i === 0) {
offset = 75;
}
var part = line.substring(o, Math.min(o + offset, line.length));
lines.push(part);
o += offset;
}
return lines.join('\r\n ');
};
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vobject",
"description": "iCalendar VObject Manipulation in NodeJS",
"version": "0.1.1",
"version": "0.1.2",
"author": {
"name": "Microsoft Outlook"
},
Expand All @@ -21,13 +21,13 @@
"url": "https://github.com/outlook/vobject-js/issues"
},
"dependencies": {
"moment-timezone": "0.5.10",
"moment-timezone": "^0.5.14",
"underscore": "1.8.3"
},
"devDependencies": {
"mocha": "3.2.0",
"jshint": "2.9.4",
"nsp": "2.6.2"
"jshint": "^2.9.5",
"mocha": "^4.1.0",
"nsp": "^3.1.0"
},
"scripts": {
"jshint": "./node_modules/.bin/jshint index.js lib/* test/*",
Expand Down
6 changes: 5 additions & 1 deletion test/vobject/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ describe('lib/vobject/property.js', function() {

it('should fold at 75 characters', function() {
var property = vobject.property('DESCRIPTION', 'Interactive Telecommunications Program\\nTisch School of the Arts\\nNew York University\\n721 Broadway\\, 4th Floor\\, South Elevators\\nNew York NY 10003\\n\\nTake the left elevators to the 4th Floor\\nThis event is free and open to the public\\nNo need to RSVP');
assert.equal(property.toICS(), 'DESCRIPTION:Interactive Telecommunications Program\\nTisch School of the Art\r\n s\\nNew York University\\n721 Broadway\\, 4th Floor\\, South Elevators\\nNew Yor\r\n k NY 10003\\n\\nTake the left elevators to the 4th Floor\\nThis event is free \r\n and open to the public\\nNo need to RSVP');
assert.equal(property.toICS(), 'DESCRIPTION:Interactive Telecommunications Program\\nTisch School of the Art\r\n s\\nNew York University\\n721 Broadway\\, 4th Floor\\, South Elevators\\nNew Yo\r\n rk NY 10003\\n\\nTake the left elevators to the 4th Floor\\nThis event is fre\r\n e and open to the public\\nNo need to RSVP');

property.toICS().split('\r\n').forEach(function(s) {
return assert.equal(s.length <= 75, true);
});
});
});
});