@optimiser/common 1.0.393 → 1.0.394

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.
@@ -22,6 +22,7 @@ export default class AwsServices {
22
22
  DeleteFile(Bucket: string, Key: string, id: string, db: mongo.Db): Promise<Error | AnyObjectInterface>;
23
23
  GetFile(BucketName: string, Region: string, FilePath: string): Promise<S3.GetObjectOutput>;
24
24
  getDownloadUrl(CDN: string, FilePath: string, FileName: string, action: string, expiry?: number): Promise<any>;
25
+ EncodeFileName(fileName: string): string;
25
26
  GetFileStream(CDN: string, Key: string, FileName: string): Promise<request.Request>;
26
27
  ChangesACL(BucketName: string, FilePath: string): Promise<S3.PutObjectAclOutput | aws.AWSError>;
27
28
  GetSignedUrl(BucketName: string, Region: string, FilePath: string): string;
@@ -144,7 +144,7 @@ var AwsServices = /** @class */ (function () {
144
144
  encodedurl = "".concat(CDN, "/").concat(FilePath);
145
145
  }
146
146
  else {
147
- FileName = FileName.replace(/[;]/g, "%3b").replace(/[,]/g, "%2c").replace(/[']/g, "%27"); //converting special character to UTF-8
147
+ FileName = this.EncodeFileName(FileName);
148
148
  encodedurl = "".concat(CDN, "/").concat(FilePath, "?response-content-disposition=").concat(encodeURIComponent("attachment;filename=" + FileName));
149
149
  }
150
150
  signingParams = {
@@ -164,6 +164,11 @@ var AwsServices = /** @class */ (function () {
164
164
  });
165
165
  });
166
166
  };
167
+ AwsServices.prototype.EncodeFileName = function (fileName) {
168
+ return fileName.split('').map(function (char) {
169
+ return /[A-Za-z0-9_\-\.]/.test(char) ? char : encodeURIComponent(char);
170
+ }).join('');
171
+ };
167
172
  AwsServices.prototype.GetFileStream = function (CDN, Key, FileName) {
168
173
  var _this = this;
169
174
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.393",
3
+ "version": "1.0.394",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {