Search code examples
icalendar

Is it a good idea to use a URL as an iCalendar UID?


iCalendar has a UID field which is a universal identifier. It's intended to be unique value so the same event can be recognized when syncing or trying to add the same event twice. They're usually randomly generated, eg. a37c3632-3c26-4543-b91d-355a1b668a3a.

I'm tempted to use a URL describing the event as my UID. Is there any reason this isn't a good idea?


Solution

  • While strictly speaking this may not be forbidden, if you do care about interoperability, you are always taking a risk by not following common practices. There will be some client or server out there which will choke on your events. For example, some CalDAV servers tend to use the UID value as the last segment in CalDAV resource URLs. With your type of UID, they will need to URI encode that last segment, which some of them may fail to do.

    Of course you can always put the blame on those bad implementations but, at the end of the day, it will be your users who will be unable to see your events.

    There are new recommendations for the UID property which were published as part of RFC 7986 (see https://www.rfc-editor.org/rfc/rfc7986#section-5.3 ). Although the main purpose of this section is to allow use of UID in VCALENDAR, the recommended format make sense in all cases.

    I would use a URL or X- property to convey your URL if you do care about it.