fix: empty string for age header failing

This commit is contained in:
Bobby 2022-05-08 12:00:27 +07:00
parent 04d2dff0f6
commit f3b7d5e56d
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -250,14 +250,11 @@ self.assertRetentionPeriod = (user, age) => {
throw new ClientError('You are not eligible for any file retention periods.', { statusCode: 403 }) throw new ClientError('You are not eligible for any file retention periods.', { statusCode: 403 })
} }
let parsed = null let parsed = parseFloat(age)
if (age === undefined || age === null) { if (Number.isNaN(parsed) || age < 0) {
parsed = utils.retentions.default[group] parsed = utils.retentions.default[group]
} else { } else if (!utils.retentions.periods[group].includes(parsed)) {
parsed = parseFloat(age) throw new ClientError('You are not eligible for the specified file retention period.', { statusCode: 403 })
if (!utils.retentions.periods[group].includes(parsed)) {
throw new ClientError('You are not eligible for the specified file retention period.', { statusCode: 403 })
}
} }
if (!parsed && !utils.retentions.periods[group].includes(0)) { if (!parsed && !utils.retentions.periods[group].includes(0)) {