hsu-utils 0.0.53 → 0.0.54

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.52
3
+ * hsu-utils v0.0.53
4
4
  *
5
5
  * some front-end utils
6
6
  *
@@ -1,2 +1,8 @@
1
- export declare function getFileNameFromHeader(response: Response): string | null;
1
+ type ResponseLike = Response | {
2
+ headers: Record<string, string> | {
3
+ get(name: string): string | null;
4
+ };
5
+ };
6
+ export declare function getFileNameFromHeader(response: ResponseLike): string | null;
2
7
  export default function downloadFile(file: ArrayBuffer | Blob | string, fileName?: string, signal?: AbortSignal): Promise<void>;
8
+ export {};
@@ -9,7 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { Typeof } from '..';
11
11
  export function getFileNameFromHeader(response) {
12
- const contentDisposition = response.headers.get('Content-Disposition');
12
+ let contentDisposition = null;
13
+ if (response.headers && typeof response.headers.get === 'function') {
14
+ contentDisposition = response.headers.get('Content-Disposition');
15
+ }
16
+ else if (response.headers && typeof response.headers === 'object') {
17
+ const headers = response.headers;
18
+ contentDisposition = headers['content-disposition'] || headers['Content-Disposition'] || null;
19
+ }
13
20
  if (!contentDisposition) {
14
21
  return null;
15
22
  }
@@ -1,2 +1,8 @@
1
- export declare function getFileNameFromHeader(response: Response): string | null;
1
+ type ResponseLike = Response | {
2
+ headers: Record<string, string> | {
3
+ get(name: string): string | null;
4
+ };
5
+ };
6
+ export declare function getFileNameFromHeader(response: ResponseLike): string | null;
2
7
  export default function downloadFile(file: ArrayBuffer | Blob | string, fileName?: string, signal?: AbortSignal): Promise<void>;
8
+ export {};
@@ -39,7 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getFileNameFromHeader = void 0;
40
40
  var __1 = require("..");
41
41
  function getFileNameFromHeader(response) {
42
- var contentDisposition = response.headers.get('Content-Disposition');
42
+ var contentDisposition = null;
43
+ if (response.headers && typeof response.headers.get === 'function') {
44
+ contentDisposition = response.headers.get('Content-Disposition');
45
+ }
46
+ else if (response.headers && typeof response.headers === 'object') {
47
+ var headers = response.headers;
48
+ contentDisposition = headers['content-disposition'] || headers['Content-Disposition'] || null;
49
+ }
43
50
  if (!contentDisposition) {
44
51
  return null;
45
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hsu-utils",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "description": "some front-end utils",
5
5
  "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
6
  "author": "VitaHsu <vitahsu7@gmail.com>",