@dsivd/prestations-ng 16.1.0-beta.1 → 16.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2127,7 +2127,14 @@ class UploaderHelper {
2127
2127
  this._accept = value;
2128
2128
  }
2129
2129
  getMaxFileSizeInBytesForFormKey(formKey) {
2130
- return this._fileMaxSizeInBytesByFormKey[formKey];
2130
+ const byFormKey = this._fileMaxSizeInBytesByFormKey[formKey];
2131
+ if (!isNaN(byFormKey)) {
2132
+ return byFormKey;
2133
+ }
2134
+ else {
2135
+ const keyAsRegex = Object.keys(this._fileMaxSizeInBytesByFormKey).find(canBeARegex => formKey.match(canBeARegex));
2136
+ return this._fileMaxSizeInBytesByFormKey[keyAsRegex];
2137
+ }
2131
2138
  }
2132
2139
  isFileTooBig(formKey, fileSizeInBytes) {
2133
2140
  return this.isTooBig(fileSizeInBytes, this.getMaxFileSizeInBytesForFormKey(formKey));
@@ -2348,7 +2355,7 @@ class UploaderHelper {
2348
2355
  const formattedErrorMsg = errorMsg.replace('%1$s', fileName);
2349
2356
  if (errorCode.startsWith('413')) {
2350
2357
  // REQUEST_ENTITY_TOO_LARGE_ERROR_MSG
2351
- const fileMaxSize = (this._fileMaxSizeInBytesByFormKey[name] /
2358
+ const fileMaxSize = (this.getMaxFileSizeInBytesForFormKey(name) /
2352
2359
  (1024 * 1024)).toString();
2353
2360
  return formattedErrorMsg.replace('%2$s', fileMaxSize);
2354
2361
  }