diff --git a/ving/docs/change-log.md b/ving/docs/change-log.md index 6606ce24..7b5f2d56 100644 --- a/ving/docs/change-log.md +++ b/ving/docs/change-log.md @@ -9,6 +9,7 @@ outline: deep * Fix a bug in redis client where it wouldn't connect to the AWS valkey/redis cluster. * Fix a hydration mismatch in form inputs subtext. * Fix a hydration mismatch in markdown inputs. + * Added error hanlding to verifyExtension() in S3File. ### 2024-10-24 * Installed dotenv for environment variables. diff --git a/ving/record/records/S3File.mjs b/ving/record/records/S3File.mjs index 3e9640b3..0398738e 100644 --- a/ving/record/records/S3File.mjs +++ b/ving/record/records/S3File.mjs @@ -221,6 +221,8 @@ export class S3FileRecord extends VingRecord { * await s3file.verifyExtension(['png','gif','jpeg','jpg']) */ async verifyExtension(whitelist, errorOnly = false) { + if (!isArray(whitelist)) + throw ving.ouch(500, 'The whitelist must be an array of allowed file extensions defined in the ving schema.'); if (!whitelist.includes(this.get('extension'))) await this.markVerifiyFailed(`${this.get('filename')} needs to be one of ${whitelist.join(', ')}.`, errorOnly); return true;