diff --git a/src/ICalendar.js b/src/ICalendar.js index a0e28606..8372d80d 100644 --- a/src/ICalendar.js +++ b/src/ICalendar.js @@ -65,9 +65,9 @@ export default class ICalendar extends CalendarBase { * @returns {String} */ render () { - const description = formatText(this.description, 62) - const location = formatText(this.location, 64) - const summary = formatText(this.title, 66) + const description = formatText(this.description) + const location = formatText(this.location) + const summary = formatText(this.title) const event = [ 'CLASS:PUBLIC', `DESCRIPTION:${description}`, diff --git a/src/__tests__/ICalendar.spec.js b/src/__tests__/ICalendar.spec.js index 8c5812d4..5f00764c 100644 --- a/src/__tests__/ICalendar.spec.js +++ b/src/__tests__/ICalendar.spec.js @@ -101,11 +101,11 @@ describe('ICalendar', () => { 'VERSION:2.0', 'BEGIN:VEVENT', 'CLASS:PUBLIC', - `DESCRIPTION:${baseOpts.description} formatted 62`, + `DESCRIPTION:${baseOpts.description}`, `DTSTART:${moment(baseOpts.start).format(dtFormat)}`, `DTEND:${moment(baseOpts.end).format(dtFormat)}`, - `LOCATION:${baseOpts.location} formatted 64`, - `SUMMARY:${baseOpts.title} formatted 66`, + `LOCATION:${baseOpts.location}`, + `SUMMARY:${baseOpts.title}`, 'TRANSP:TRANSPARENT', 'END:VEVENT', 'END:VCALENDAR', diff --git a/src/utils/__tests__/ics.spec.js b/src/utils/__tests__/ics.spec.js index 91b526ad..7bcfbd0b 100644 --- a/src/utils/__tests__/ics.spec.js +++ b/src/utils/__tests__/ics.spec.js @@ -52,12 +52,6 @@ describe('IcsUtil', () => { expect(formatted).toBe('foo\\nbar\\n\\nbaz') }) - - it('should truncate the string after backslash escaping newlines', () => { - const formatted = formatText(str, 10) - - expect(formatted).toBe('foo\\nbar\\n') - }) }) describe('getBlob()', () => { diff --git a/src/utils/ics.js b/src/utils/ics.js index 835adfb4..334cd679 100644 --- a/src/utils/ics.js +++ b/src/utils/ics.js @@ -8,17 +8,14 @@ import safariFileSave from './safariFileSave' * longer than maxLength chars (or 75 chars if none specified). * * @param {String} str - string to sanitize - * @param {Number} maxLength * @returns {String} */ -export const formatText = (str, maxLength) => { +export const formatText = (str) => { if (!str) { return '' } - str = str.replace(/\n/g, '\\n') - str = str.substring(0, maxLength) - - return str + + return str.replace(/\n/g, '\\n') } /**