Skip to content

Commit

Permalink
Add support to exclude property's trailing semicolon if no value is set
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Jul 1, 2016
1 parent a7e3dde commit 370c91a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/ics-js.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ics-js.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/Property.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export default class Property {
const hasProps = Object.keys(this.props).length > 0
const key = this.constructor.propName + (hasProps ? ';' + this.transformedProps() : '')
const value = this.transformedValue()
const keyValuePair = key + ':' + value

let keyValuePair = key
if (value) {
keyValuePair += ':' + value
}

return keyValuePair.match(/.{1,75}/g).join('\r\n ')
}
Expand Down
8 changes: 8 additions & 0 deletions test/integration/ics-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ event.addProp('DTSTAMP', new Date('2015-07-18'), { VALUE: 'DATE' })
event.addProp('SUMMARY', 'Birthdate')
event.addProp('DTSTART', new Date('1991-03-07 07:00:00'), { VALUE: 'DATE-TIME' })
event.addProp('DTEND', new Date('1991-03-07 19:30:00'))
event.addProp('ATTENDEE', null, {
CN: 'Sample Company',
RSVP: [
'FALSE:[email protected]',
'TRUE:[email protected]'
]
})

const eventAlarm = new ICS.VALARM()

Expand Down Expand Up @@ -44,6 +51,7 @@ const icsString = 'BEGIN:VCALENDAR\r\n' +
'SUMMARY:Birthdate\r\n' +
'DTSTART;VALUE=DATE-TIME:19910307T070000\r\n' +
'DTEND:19910307T193000\r\n' +
'ATTENDEE;CN=Sample Company;RSVP=FALSE:[email protected],TRUE:[email protected]\r\n' +
'BEGIN:VALARM\r\n' +
'ACTION:DISPLAY\r\n' +
'TRIGGER:-PT12H\r\n' +
Expand Down

0 comments on commit 370c91a

Please sign in to comment.