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.
- package/dist/hsu-utils.js +2 -2
- package/dist/hsu-utils.min.js +1 -1
- package/dist/hsu-utils.min.js.LICENSE.txt +1 -1
- package/es/DownloadFile/index.d.ts +7 -1
- package/es/DownloadFile/index.js +8 -1
- package/lib/DownloadFile/index.d.ts +7 -1
- package/lib/DownloadFile/index.js +8 -1
- package/package.json +1 -1
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
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 {};
|
package/es/DownloadFile/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
}
|