@e-mc/request 0.11.8 → 0.12.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.11.8",
3
+ "version": "0.12.1",
4
4
  "description": "Request constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.11.8",
24
- "@e-mc/types": "0.11.8",
23
+ "@e-mc/module": "0.12.1",
24
+ "@e-mc/types": "0.12.1",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "picomatch": "^4.0.2",
package/util.js CHANGED
@@ -28,37 +28,39 @@ const host_1 = require("@e-mc/request/http/host");
28
28
  const safeInt = (value) => value >= 0 ? Math.min(value, Number.MAX_SAFE_INTEGER) : NaN;
29
29
  function parseHeader(headers, name) {
30
30
  const value = headers[name];
31
- if (value) {
32
- switch (name.toLowerCase()) {
33
- case 'content-disposition': {
34
- let result;
35
- for (const match of value.matchAll(/\bfilename(?:\*\s*=\s*UTF-8''([^\s;]+)|\s*=\s*(?:"([^"]+)"|([^\s;]+)))/gi)) {
36
- if (match[1]) {
37
- return decodeURIComponent(match[1]).trim();
38
- }
39
- result = (match[2] || match[3]).trim();
31
+ if (!value) {
32
+ return;
33
+ }
34
+ switch (name.toLowerCase()) {
35
+ case 'content-disposition': {
36
+ let result;
37
+ for (const match of value.matchAll(/\bfilename(?:\*\s*=\s*UTF-8''([^\s;]+)|\s*=\s*(?:"([^"]+)"|([^\s;]+)))/gi)) {
38
+ if (match[1]) {
39
+ return decodeURIComponent(match[1]).trim();
40
40
  }
41
- return result;
41
+ result = (match[2] || match[3]).trim();
42
42
  }
43
+ return result;
43
44
  }
44
45
  }
45
46
  }
46
47
  function parseOutgoingHeaders(headers) {
47
- if (headers) {
48
- if (globalThis.Headers && headers instanceof Headers) {
49
- const result = {};
50
- headers.forEach((value, key) => {
51
- if (key === 'set-cookie') {
52
- (result[key] ||= []).push(value);
53
- }
54
- else {
55
- result[key] = value;
56
- }
57
- });
58
- return result;
59
- }
60
- return headers;
48
+ if (!headers) {
49
+ return;
50
+ }
51
+ if (headers instanceof Headers) {
52
+ const result = {};
53
+ headers.forEach((value, key) => {
54
+ if (key === 'set-cookie') {
55
+ (result[key] ||= []).push(value);
56
+ }
57
+ else {
58
+ result[key] = value;
59
+ }
60
+ });
61
+ return result;
61
62
  }
63
+ return { ...headers };
62
64
  }
63
65
  function normalizeHeaders(headers) {
64
66
  const result = Object.create(null);
@@ -392,8 +394,8 @@ function getSize(value, diskUsed) {
392
394
  return (diskUsed ? fs.lstatSync(value) : fs.statSync(value)).size;
393
395
  }
394
396
  catch {
395
- return 0;
396
397
  }
398
+ return 0;
397
399
  }
398
400
  function hasSameStat(src, dest, keepEmpty) {
399
401
  try {
@@ -424,9 +426,8 @@ function cleanupStream(stream, uri) {
424
426
  }
425
427
  }
426
428
  catch (err) {
427
- if (module_1.isErrorCode(err, 'ENOENT')) {
428
- return;
429
+ if (!module_1.isErrorCode(err, 'ENOENT')) {
430
+ module_1.writeFail(["Unable to delete file", path.basename(uri)], err, 32);
429
431
  }
430
- module_1.writeFail(["Unable to delete file", path.basename(uri)], err, 32);
431
432
  }
432
433
  }