Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump jsdoc from 3.6.11 to 4.0.2 #12

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
11 changes: 8 additions & 3 deletions lib/ical/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,18 @@ class Event {
}

/**
* Checks if the event is recurring
* Checks if the event is recurring, thus has an RRULE or RDATE property, or a
* RECURRENCE-ID with the respective RANGE parameter.
*
* @return {Boolean} True, if event is recurring
*/
isRecurring() {
let comp = this.component;
return comp.hasProperty('rrule') || comp.hasProperty('rdate');
let comp = this.component, recurrenceId;
if (comp.hasProperty('rrule') || comp.hasProperty('rdate')) {
recurrenceId = comp.getFirstProperty('recurrence-id');
return !recurrenceId || !!recurrenceId.getParameter('range');
}
return false;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions lib/ical/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ parse._parseParameters = function(line, start, designSet) {
// then increment pos to find next ;

while ((pos !== false) &&
(pos = unescapedIndexOf(line, delim, pos + 1)) !== -1) {
(pos = line.indexOf(delim, pos + 1)) !== -1) {

name = line.slice(lastParam + 1, pos);
if (name.length == 0) {
Expand All @@ -370,12 +370,12 @@ parse._parseParameters = function(line, start, designSet) {
let nextChar = line[pos + 1];
if (nextChar === '"') {
valuePos = pos + 2;
pos = unescapedIndexOf(line, '"', valuePos);
pos = line.indexOf('"', valuePos);
if (multiValue && pos != -1) {
let extendedValue = true;
while (extendedValue) {
if (line[pos + 1] == multiValue && line[pos + 2] == '"') {
pos = unescapedIndexOf(line, '"', pos + 3);
pos = line.indexOf('"', pos + 3);
} else {
extendedValue = false;
}
Expand All @@ -387,16 +387,16 @@ parse._parseParameters = function(line, start, designSet) {
);
}
value = line.slice(valuePos, pos);
lastParam = unescapedIndexOf(line, PARAM_DELIMITER, pos);
lastParam = line.indexOf(PARAM_DELIMITER, pos);
if (lastParam === -1) {
pos = false;
}
} else {
valuePos = pos + 1;

// move to next ";"
let nextPos = unescapedIndexOf(line, PARAM_DELIMITER, valuePos);
let propValuePos = unescapedIndexOf(line, VALUE_DELIMITER, valuePos);
let nextPos = line.indexOf(PARAM_DELIMITER, valuePos);
let propValuePos = line.indexOf(VALUE_DELIMITER, valuePos);
if (propValuePos !== -1 && nextPos > propValuePos) {
// this is a delimiter in the property value, let's stop here
nextPos = propValuePos;
Expand All @@ -417,7 +417,9 @@ parse._parseParameters = function(line, start, designSet) {
value = line.slice(valuePos, nextPos);
}

const length_before = value.length;
value = parse._rfc6868Escape(value);
valuePos += length_before - value.length;
if (multiValue) {
let delimiter = mvdelim || multiValue;
value = parse._parseMultiValue(value, delimiter, type, [], null, designSet);
Expand Down
41 changes: 33 additions & 8 deletions lib/ical/recur_expansion.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class RecurExpansion {
* @type {Number}
* @private
*/
ruleDateInc = 0;
ruleDateInc = -1;

/**
* Current position in exDates array
Expand Down Expand Up @@ -198,6 +198,21 @@ class RecurExpansion {
}
}

/**
* Compare two ICAL.Time objects. When the second parameter is a timeless date
* and the first parameter is date-with-time, strip the time and compare only
* the days.
*
* @private
* @param {ICAL.Time} a The one object to compare
* @param {ICAL.Time} b The other object to compare
*/
_compare_special(a, b) {
if (!a.isDate && b.isDate)
return new Time({ year: a.year, month: a.month, day: a.day }).compare(b);
else return a.compare(b);
}

/**
* Retrieve the next occurrence in the series.
* @return {ICAL.Time}
Expand Down Expand Up @@ -225,6 +240,14 @@ class RecurExpansion {
// _after_ we choose a value this should be
// the only spot where we need to worry about the
// end of events.
if (this.ruleDateInc == -1) {
this._nextRuleDay();
if (!iter) {
// on the first iteration return DTSTART
return this.last;
}
}

if (!next && !iter) {
// there are no more iterators or rdates
this.complete = true;
Expand All @@ -248,9 +271,10 @@ class RecurExpansion {

// check the negative rules
if (this.exDate) {
compare = this.exDate.compare(this.last);
//EXDATE can be in DATE format, but DTSTART is in DATE-TIME format
compare = this._compare_special(this.last, this.exDate);

if (compare < 0) {
if (compare > 0) {
this._nextExDay();
}

Expand All @@ -262,7 +286,7 @@ class RecurExpansion {
}

//XXX: The spec states that after we resolve the final
// list of dates we execute exdate this seems somewhat counter
// list of dates we execute exdate. This seems somewhat counter
// intuitive to what I have seen most servers do so for now
// I exclude based on the original date not the one that may
// have been modified by the exception.
Expand Down Expand Up @@ -363,15 +387,14 @@ class RecurExpansion {

this.ruleDateInc = 0;
this.last = this.ruleDates[0].clone();
this.ruleDate = this.ruleDates[0];
} else {
this.ruleDateInc = binsearchInsert(
this.ruleDates,
this.last,
(a, b) => a.compare(b)
);
) - 1;
}

this.ruleDate = this.ruleDates[this.ruleDateInc];
}

if (component.hasProperty('rrule')) {
Expand All @@ -397,10 +420,12 @@ class RecurExpansion {
if (component.hasProperty('exdate')) {
this.exDates = this._extractDates(component, 'exdate');
// if we have a .last day we increment the index to beyond it.
// When DTSTART is in DATE-TIME format, EXDATE is in DATE format and EXDATE is
// the date of DTSTART, _compare_special finds this out and compareTime fails.
this.exDateInc = binsearchInsert(
this.exDates,
this.last,
(a, b) => a.compare(b)
this._compare_special
);

this.exDate = this.exDates[this.exDateInc];
Expand Down
17 changes: 8 additions & 9 deletions lib/ical/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Portions Copyright (C) Philipp Kewisch */

import design from "./design.js";
import { foldline, unescapedIndexOf } from "./helpers.js";
import { foldline } from "./helpers.js";

const LINE_ENDING = '\r\n';
const DEFAULT_VALUE_TYPE = 'unknown';
Expand Down Expand Up @@ -127,9 +127,8 @@ stringify.property = function(property, designSet, noFold) {
value = stringify._rfc6868Unescape(value);
}


line += ';' + paramName.toUpperCase();
line += '=' + stringify.propertyValue(value);
line += '=' + stringify.propertyParameterValue(value);
}

if (property.length === 3) {
Expand Down Expand Up @@ -206,15 +205,15 @@ stringify.property = function(property, designSet, noFold) {
* If any of the above are present the result is wrapped
* in double quotes.
*
* @function ICAL.stringify.propertyValue
* @function ICAL.stringify.propertyParameterValue
* @param {String} value Raw property value
* @return {String} Given or escaped value when needed
*/
stringify.propertyValue = function(value) {

if ((unescapedIndexOf(value, ',') === -1) &&
(unescapedIndexOf(value, ':') === -1) &&
(unescapedIndexOf(value, ';') === -1)) {
stringify.propertyParameterValue = function(value, force) {
if (!force &&
(value.indexOf(',') === -1) &&
(value.indexOf(':') === -1) &&
(value.indexOf(';') === -1)) {

return value;
}
Expand Down
Loading