@@ -32,18 +32,23 @@ module.exports = function (options) {
3232        fullData : true 
3333      } ) ; 
3434
35-       if  ( ctx . accepts ( 'text/calendar' ) ) 
36-         return  options . data . buildICS ( ctx ,  events ,  calendar ) ; 
37- 
3835      const  ics  =  await  options . data . buildICS ( ctx ,  events ,  calendar ) ; 
39-       return  response ( ctx . url ,  status [ 200 ] ,  [ 
40-         { 
41-           'D:getetag' : options . data . getETag ( ctx ,  calendar ) 
42-         } , 
43-         { 
44-           'CAL:calendar-data' : encodeXMLEntities ( ics ) 
45-         } 
46-       ] ) ; 
36+       if  ( 
37+         ctx . accepts ( 'text/xml' )  || 
38+         ! ctx . accepts ( 'text/calendar' )  || 
39+         ! ctx . accepts ( 'application/ics' )  || 
40+         ! ctx . accepts ( 'text/x-vcalendar' )  || 
41+         ! ctx . accepts ( 'application/octet-stream' ) 
42+       ) 
43+         return  response ( ctx . url ,  status [ 200 ] ,  [ 
44+           { 
45+             'D:getetag' : options . data . getETag ( ctx ,  calendar ) 
46+           } , 
47+           { 
48+             'CAL:calendar-data' : encodeXMLEntities ( ics ) 
49+           } 
50+         ] ) ; 
51+       return  ics ; 
4752    } 
4853
4954    const  event  =  await  options . data . getEvent ( ctx ,  { 
@@ -59,20 +64,27 @@ module.exports = function (options) {
5964      return ; 
6065    } 
6166
62-     if  ( ctx . accepts ( 'text/calendar' ) ) 
63-       return  options . data . buildICS ( ctx ,  event ,  calendar ) ; 
64- 
6567    const  ics  =  await  options . data . buildICS ( ctx ,  event ,  calendar ) ; 
66-     return  response ( ctx . url ,  status [ 200 ] ,  [ 
67-       { 
68-         // TODO: should E-Tag here be of calendar or event? 
69-         // 'D:getetag': options.data.getETag(ctx, calendar) 
70-         'D:getetag' : options . data . getETag ( ctx ,  calendar ) 
71-       } , 
72-       { 
73-         'CAL:calendar-data' : encodeXMLEntities ( ics ) 
74-       } 
75-     ] ) ; 
68+ 
69+     if  ( 
70+       ctx . accepts ( 'text/xml' )  || 
71+       ! ctx . accepts ( 'text/calendar' )  || 
72+       ! ctx . accepts ( 'application/ics' )  || 
73+       ! ctx . accepts ( 'text/x-vcalendar' )  || 
74+       ! ctx . accepts ( 'application/octet-stream' ) 
75+     ) 
76+       return  response ( ctx . url ,  status [ 200 ] ,  [ 
77+         { 
78+           // TODO: should E-Tag here be of calendar or event? 
79+           // 'D:getetag': options.data.getETag(ctx, calendar) 
80+           'D:getetag' : options . data . getETag ( ctx ,  calendar ) 
81+         } , 
82+         { 
83+           'CAL:calendar-data' : encodeXMLEntities ( ics ) 
84+         } 
85+       ] ) ; 
86+ 
87+     return  ics ; 
7688  } ; 
7789
7890  return  { 
0 commit comments