in lib/lambda-functions/helpers/src/isoDurationUtility.ts [55:83]
export function parseISODurationString(durationStr: string): Duration {
const match = durationRegex.exec(durationStr);
if (!match || !match.groups) {
throw InvalidDurationError;
}
let empty = true;
const values: DurationValues = {};
for (const { unit } of units) {
if (Object.prototype.hasOwnProperty.call(match.groups, unit)) {
empty = false;
Object.assign(values, {
// Eslint disable rule in place because the user input has already been validated earlier and also in line 62 , validation that match.groups has the unit property is done
/* eslint-disable security/detect-object-injection */
[unit]: parseNum(match.groups[unit]),
});
}
}
if (empty) {
throw InvalidDurationError;
}
const duration: Duration = values;
if (match.groups.negative) {
duration.negative = true;
}
return duration;
}