@gjsify/fetch 0.0.2 → 0.0.4
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/lib/cjs/body.js +65 -94
- package/lib/cjs/errors/abort-error.js +5 -24
- package/lib/cjs/errors/base.js +3 -22
- package/lib/cjs/errors/fetch-error.js +5 -24
- package/lib/cjs/headers.js +19 -48
- package/lib/cjs/index.js +70 -92
- package/lib/cjs/request.js +38 -63
- package/lib/cjs/response.js +18 -47
- package/lib/cjs/types/index.js +1 -17
- package/lib/cjs/types/system-error.js +0 -15
- package/lib/cjs/utils/blob-from.js +38 -61
- package/lib/cjs/utils/get-search.js +3 -22
- package/lib/cjs/utils/is-redirect.js +3 -22
- package/lib/cjs/utils/is.js +12 -31
- package/lib/cjs/utils/multipart-parser.js +7 -26
- package/lib/cjs/utils/referrer.js +17 -36
- package/package.json +11 -11
- package/test.gjs.mjs +669 -674
- package/test.node.mjs +71 -92
- package/tsconfig.json +1 -1
|
@@ -1,82 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var blob_from_exports = {};
|
|
29
|
-
__export(blob_from_exports, {
|
|
30
|
-
Blob: () => import_file.Blob,
|
|
31
|
-
File: () => import_file.File,
|
|
32
|
-
blobFrom: () => blobFrom,
|
|
33
|
-
blobFromSync: () => blobFromSync,
|
|
34
|
-
createTemporaryBlob: () => createTemporaryBlob,
|
|
35
|
-
createTemporaryFile: () => createTemporaryFile,
|
|
36
|
-
default: () => blob_from_default,
|
|
37
|
-
fileFrom: () => fileFrom,
|
|
38
|
-
fileFromSync: () => fileFromSync
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(blob_from_exports);
|
|
41
|
-
var import_dom_exception = require("@gjsify/deno-runtime/ext/web/01_dom_exception");
|
|
42
|
-
var import_file = require("@gjsify/deno-runtime/ext/web/09_file");
|
|
43
|
-
var import_node_fs = require("node:fs");
|
|
44
|
-
var import_node_path = require("node:path");
|
|
45
|
-
var import_node_os = require("node:os");
|
|
46
|
-
var import_node_process = __toESM(require("node:process"), 1);
|
|
47
|
-
const { stat, mkdtemp } = import_node_fs.promises;
|
|
1
|
+
import { DOMException } from "@gjsify/deno-runtime/ext/web/01_dom_exception";
|
|
2
|
+
import { Blob, File } from "@gjsify/deno-runtime/ext/web/09_file";
|
|
3
|
+
import {
|
|
4
|
+
realpathSync,
|
|
5
|
+
statSync,
|
|
6
|
+
rmdirSync,
|
|
7
|
+
createReadStream,
|
|
8
|
+
promises as fs
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { basename, sep, join } from "node:path";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import process from "node:process";
|
|
13
|
+
const { stat, mkdtemp } = fs;
|
|
48
14
|
let i = 0, tempDir, registry;
|
|
49
|
-
const blobFromSync = (path, type) => fromBlob(
|
|
15
|
+
const blobFromSync = (path, type) => fromBlob(statSync(path), path, type);
|
|
50
16
|
const blobFrom = (path, type) => stat(path).then((stat2) => fromBlob(stat2, path, type));
|
|
51
17
|
const fileFrom = (path, type) => stat(path).then((stat2) => fromFile(stat2, path, type));
|
|
52
|
-
const fileFromSync = (path, type) => fromFile(
|
|
53
|
-
const fromBlob = (stat2, path, type = "") => new
|
|
18
|
+
const fileFromSync = (path, type) => fromFile(statSync(path), path, type);
|
|
19
|
+
const fromBlob = (stat2, path, type = "") => new Blob([new BlobDataItem({
|
|
54
20
|
path,
|
|
55
21
|
size: stat2.size,
|
|
56
22
|
lastModified: stat2.mtimeMs,
|
|
57
23
|
start: 0
|
|
58
24
|
})], { type });
|
|
59
|
-
const fromFile = (stat2, path, type = "") => new
|
|
25
|
+
const fromFile = (stat2, path, type = "") => new File([new BlobDataItem({
|
|
60
26
|
path,
|
|
61
27
|
size: stat2.size,
|
|
62
28
|
lastModified: stat2.mtimeMs,
|
|
63
29
|
start: 0
|
|
64
|
-
})],
|
|
30
|
+
})], basename(path), { type, lastModified: stat2.mtimeMs });
|
|
65
31
|
const createTemporaryBlob = async (data, { signal, type } = {}) => {
|
|
66
|
-
registry = registry || new FinalizationRegistry(
|
|
67
|
-
tempDir = tempDir || await mkdtemp(
|
|
32
|
+
registry = registry || new FinalizationRegistry(fs.unlink);
|
|
33
|
+
tempDir = tempDir || await mkdtemp(realpathSync(tmpdir()) + sep);
|
|
68
34
|
const id = `${i++}`;
|
|
69
|
-
const destination =
|
|
35
|
+
const destination = join(tempDir, id);
|
|
70
36
|
if (data instanceof ArrayBuffer)
|
|
71
37
|
data = new Uint8Array(data);
|
|
72
|
-
await
|
|
38
|
+
await fs.writeFile(destination, data, { signal });
|
|
73
39
|
const blob = await blobFrom(destination, type);
|
|
74
40
|
registry.register(blob, destination);
|
|
75
41
|
return blob;
|
|
76
42
|
};
|
|
77
43
|
const createTemporaryFile = async (data, name, opts) => {
|
|
78
44
|
const blob = await createTemporaryBlob(data);
|
|
79
|
-
return new
|
|
45
|
+
return new File([blob], name, opts);
|
|
80
46
|
};
|
|
81
47
|
class BlobDataItem {
|
|
82
48
|
#path;
|
|
@@ -107,9 +73,9 @@ class BlobDataItem {
|
|
|
107
73
|
async *stream() {
|
|
108
74
|
const { mtimeMs, size } = await stat(this.#path);
|
|
109
75
|
if (mtimeMs > this.lastModified || this.originalSize !== size) {
|
|
110
|
-
throw new
|
|
76
|
+
throw new DOMException("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.", "NotReadableError");
|
|
111
77
|
}
|
|
112
|
-
yield*
|
|
78
|
+
yield* createReadStream(this.#path, {
|
|
113
79
|
start: this.#start,
|
|
114
80
|
end: this.#start + this.size - 1
|
|
115
81
|
});
|
|
@@ -118,7 +84,18 @@ class BlobDataItem {
|
|
|
118
84
|
return "Blob";
|
|
119
85
|
}
|
|
120
86
|
}
|
|
121
|
-
|
|
122
|
-
tempDir &&
|
|
87
|
+
process.once("exit", () => {
|
|
88
|
+
tempDir && rmdirSync(tempDir, { recursive: true });
|
|
123
89
|
});
|
|
124
90
|
var blob_from_default = blobFromSync;
|
|
91
|
+
export {
|
|
92
|
+
Blob,
|
|
93
|
+
File,
|
|
94
|
+
blobFrom,
|
|
95
|
+
blobFromSync,
|
|
96
|
+
createTemporaryBlob,
|
|
97
|
+
createTemporaryFile,
|
|
98
|
+
blob_from_default as default,
|
|
99
|
+
fileFrom,
|
|
100
|
+
fileFromSync
|
|
101
|
+
};
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var get_search_exports = {};
|
|
19
|
-
__export(get_search_exports, {
|
|
20
|
-
getSearch: () => getSearch
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(get_search_exports);
|
|
23
1
|
const getSearch = (parsedURL) => {
|
|
24
2
|
if (parsedURL.search) {
|
|
25
3
|
return parsedURL.search;
|
|
@@ -28,3 +6,6 @@ const getSearch = (parsedURL) => {
|
|
|
28
6
|
const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
|
|
29
7
|
return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
|
|
30
8
|
};
|
|
9
|
+
export {
|
|
10
|
+
getSearch
|
|
11
|
+
};
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var is_redirect_exports = {};
|
|
19
|
-
__export(is_redirect_exports, {
|
|
20
|
-
isRedirect: () => isRedirect
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(is_redirect_exports);
|
|
23
1
|
const redirectStatus = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
24
2
|
const isRedirect = (code) => {
|
|
25
3
|
return redirectStatus.has(code);
|
|
26
4
|
};
|
|
5
|
+
export {
|
|
6
|
+
isRedirect
|
|
7
|
+
};
|
package/lib/cjs/utils/is.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var is_exports = {};
|
|
19
|
-
__export(is_exports, {
|
|
20
|
-
isAbortSignal: () => isAbortSignal,
|
|
21
|
-
isBlob: () => isBlob,
|
|
22
|
-
isDomainOrSubdomain: () => isDomainOrSubdomain,
|
|
23
|
-
isSameProtocol: () => isSameProtocol,
|
|
24
|
-
isURLSearchParameters: () => isURLSearchParameters
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(is_exports);
|
|
27
|
-
var import_url = require("@gjsify/deno-runtime/ext/url/00_url");
|
|
1
|
+
import { URL } from "@gjsify/deno-runtime/ext/url/00_url";
|
|
28
2
|
const NAME = Symbol.toStringTag;
|
|
29
3
|
const isURLSearchParameters = (object) => {
|
|
30
4
|
return typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && typeof object.sort === "function" && object[NAME] === "URLSearchParams";
|
|
@@ -36,12 +10,19 @@ const isAbortSignal = (object) => {
|
|
|
36
10
|
return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
|
|
37
11
|
};
|
|
38
12
|
const isDomainOrSubdomain = (destination, original) => {
|
|
39
|
-
const orig = new
|
|
40
|
-
const dest = new
|
|
13
|
+
const orig = new URL(original).hostname;
|
|
14
|
+
const dest = new URL(destination).hostname;
|
|
41
15
|
return orig === dest || orig.endsWith(`.${dest}`);
|
|
42
16
|
};
|
|
43
17
|
const isSameProtocol = (destination, original) => {
|
|
44
|
-
const orig = new
|
|
45
|
-
const dest = new
|
|
18
|
+
const orig = new URL(original).protocol;
|
|
19
|
+
const dest = new URL(destination).protocol;
|
|
46
20
|
return orig === dest;
|
|
47
21
|
};
|
|
22
|
+
export {
|
|
23
|
+
isAbortSignal,
|
|
24
|
+
isBlob,
|
|
25
|
+
isDomainOrSubdomain,
|
|
26
|
+
isSameProtocol,
|
|
27
|
+
isURLSearchParameters
|
|
28
|
+
};
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var multipart_parser_exports = {};
|
|
19
|
-
__export(multipart_parser_exports, {
|
|
20
|
-
toFormData: () => toFormData
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(multipart_parser_exports);
|
|
23
|
-
var import_blob_from = require("./blob-from.js");
|
|
24
|
-
var import_esm_min = require("formdata-polyfill/esm.min.js");
|
|
1
|
+
import { File } from "./blob-from.js";
|
|
2
|
+
import { FormData } from "formdata-polyfill/esm.min.js";
|
|
25
3
|
var S = /* @__PURE__ */ ((S2) => {
|
|
26
4
|
S2[S2["START_BOUNDARY"] = 0] = "START_BOUNDARY";
|
|
27
5
|
S2[S2["HEADER_FIELD_START"] = 1] = "HEADER_FIELD_START";
|
|
@@ -312,7 +290,7 @@ async function toFormData(Body, ct) {
|
|
|
312
290
|
let contentType;
|
|
313
291
|
let filename;
|
|
314
292
|
const entryChunks = [];
|
|
315
|
-
const formData = new
|
|
293
|
+
const formData = new FormData();
|
|
316
294
|
const onPartData = (ui8a) => {
|
|
317
295
|
entryValue += decoder.decode(ui8a, { stream: true });
|
|
318
296
|
};
|
|
@@ -320,7 +298,7 @@ async function toFormData(Body, ct) {
|
|
|
320
298
|
entryChunks.push(ui8a);
|
|
321
299
|
};
|
|
322
300
|
const appendFileToFormData = () => {
|
|
323
|
-
const file = new
|
|
301
|
+
const file = new File(entryChunks, filename, { type: contentType });
|
|
324
302
|
formData.append(entryName, file);
|
|
325
303
|
};
|
|
326
304
|
const appendEntryToFormData = () => {
|
|
@@ -370,3 +348,6 @@ async function toFormData(Body, ct) {
|
|
|
370
348
|
parser.end();
|
|
371
349
|
return formData;
|
|
372
350
|
}
|
|
351
|
+
export {
|
|
352
|
+
toFormData
|
|
353
|
+
};
|
|
@@ -1,39 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var referrer_exports = {};
|
|
19
|
-
__export(referrer_exports, {
|
|
20
|
-
DEFAULT_REFERRER_POLICY: () => DEFAULT_REFERRER_POLICY,
|
|
21
|
-
ReferrerPolicy: () => ReferrerPolicy,
|
|
22
|
-
determineRequestsReferrer: () => determineRequestsReferrer,
|
|
23
|
-
isOriginPotentiallyTrustworthy: () => isOriginPotentiallyTrustworthy,
|
|
24
|
-
isUrlPotentiallyTrustworthy: () => isUrlPotentiallyTrustworthy,
|
|
25
|
-
parseReferrerPolicyFromHeader: () => parseReferrerPolicyFromHeader,
|
|
26
|
-
stripURLForUseAsAReferrer: () => stripURLForUseAsAReferrer,
|
|
27
|
-
validateReferrerPolicy: () => validateReferrerPolicy
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(referrer_exports);
|
|
30
|
-
var import_url = require("@gjsify/deno-runtime/ext/url/00_url");
|
|
31
|
-
var import_net = require("net");
|
|
1
|
+
import { URL } from "@gjsify/deno-runtime/ext/url/00_url";
|
|
2
|
+
import { isIP } from "net";
|
|
32
3
|
function stripURLForUseAsAReferrer(url, originOnly = false) {
|
|
33
4
|
if (url == null || url === "no-referrer") {
|
|
34
5
|
return "no-referrer";
|
|
35
6
|
}
|
|
36
|
-
url = new
|
|
7
|
+
url = new URL(url);
|
|
37
8
|
if (/^(about|blob|data):$/.test(url.protocol)) {
|
|
38
9
|
return "no-referrer";
|
|
39
10
|
}
|
|
@@ -69,7 +40,7 @@ function isOriginPotentiallyTrustworthy(url) {
|
|
|
69
40
|
return true;
|
|
70
41
|
}
|
|
71
42
|
const hostIp = url.host.replace(/(^\[)|(]$)/g, "");
|
|
72
|
-
const hostIPVersion =
|
|
43
|
+
const hostIPVersion = isIP(hostIp);
|
|
73
44
|
if (hostIPVersion === 4 && /^127\./.test(hostIp)) {
|
|
74
45
|
return true;
|
|
75
46
|
}
|
|
@@ -89,7 +60,7 @@ function isUrlPotentiallyTrustworthy(url) {
|
|
|
89
60
|
return true;
|
|
90
61
|
}
|
|
91
62
|
if (typeof url === "string") {
|
|
92
|
-
url = new
|
|
63
|
+
url = new URL(url);
|
|
93
64
|
}
|
|
94
65
|
if (url.protocol === "data:") {
|
|
95
66
|
return true;
|
|
@@ -108,7 +79,7 @@ function determineRequestsReferrer(request, obj = {}) {
|
|
|
108
79
|
if (request.referrer === "about:client") {
|
|
109
80
|
return "no-referrer";
|
|
110
81
|
}
|
|
111
|
-
const referrerSource = new
|
|
82
|
+
const referrerSource = new URL(request.referrer);
|
|
112
83
|
let referrerURL = stripURLForUseAsAReferrer(referrerSource);
|
|
113
84
|
let referrerOrigin = stripURLForUseAsAReferrer(referrerSource, true);
|
|
114
85
|
if (referrerURL.toString().length > 4096) {
|
|
@@ -120,7 +91,7 @@ function determineRequestsReferrer(request, obj = {}) {
|
|
|
120
91
|
if (referrerOriginCallback) {
|
|
121
92
|
referrerOrigin = referrerOriginCallback(referrerOrigin);
|
|
122
93
|
}
|
|
123
|
-
const currentURL = new
|
|
94
|
+
const currentURL = new URL(request.url);
|
|
124
95
|
switch (policy) {
|
|
125
96
|
case "no-referrer":
|
|
126
97
|
return "no-referrer";
|
|
@@ -170,3 +141,13 @@ function parseReferrerPolicyFromHeader(headers) {
|
|
|
170
141
|
}
|
|
171
142
|
return policy;
|
|
172
143
|
}
|
|
144
|
+
export {
|
|
145
|
+
DEFAULT_REFERRER_POLICY,
|
|
146
|
+
ReferrerPolicy,
|
|
147
|
+
determineRequestsReferrer,
|
|
148
|
+
isOriginPotentiallyTrustworthy,
|
|
149
|
+
isUrlPotentiallyTrustworthy,
|
|
150
|
+
parseReferrerPolicyFromHeader,
|
|
151
|
+
stripURLForUseAsAReferrer,
|
|
152
|
+
validateReferrerPolicy
|
|
153
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/fetch",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Web and Node.js fetch module for Gjs",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"fetch"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@gjsify/cli": "^0.0.
|
|
40
|
-
"@gjsify/http": "^0.0.
|
|
41
|
-
"@gjsify/unit": "^0.0.
|
|
42
|
-
"@types/node": "^20.
|
|
39
|
+
"@gjsify/cli": "^0.0.4",
|
|
40
|
+
"@gjsify/http": "^0.0.4",
|
|
41
|
+
"@gjsify/unit": "^0.0.4",
|
|
42
|
+
"@types/node": "^20.10.5"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@gjsify/deno-runtime": "^0.0.
|
|
46
|
-
"@gjsify/gio-2.0": "^0.0.
|
|
47
|
-
"@gjsify/soup-3.0": "^0.0.
|
|
48
|
-
"@types/node-fetch": "^2.6.
|
|
49
|
-
"data-uri-to-buffer": "^
|
|
45
|
+
"@gjsify/deno-runtime": "^0.0.4",
|
|
46
|
+
"@gjsify/gio-2.0": "^0.0.4",
|
|
47
|
+
"@gjsify/soup-3.0": "^0.0.4",
|
|
48
|
+
"@types/node-fetch": "^2.6.10",
|
|
49
|
+
"data-uri-to-buffer": "^6.0.1",
|
|
50
50
|
"formdata-polyfill": "^4.0.10",
|
|
51
|
-
"node-fetch": "^3.3.
|
|
51
|
+
"node-fetch": "^3.3.2"
|
|
52
52
|
}
|
|
53
53
|
}
|