@gjsify/fetch 0.0.2
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/README.md +9 -0
- package/lib/cjs/body.js +284 -0
- package/lib/cjs/errors/abort-error.js +28 -0
- package/lib/cjs/errors/base.js +36 -0
- package/lib/cjs/errors/fetch-error.js +40 -0
- package/lib/cjs/headers.js +231 -0
- package/lib/cjs/index.js +246 -0
- package/lib/cjs/request.js +306 -0
- package/lib/cjs/response.js +162 -0
- package/lib/cjs/types/index.js +17 -0
- package/lib/cjs/types/system-error.js +16 -0
- package/lib/cjs/utils/blob-from.js +124 -0
- package/lib/cjs/utils/get-search.js +30 -0
- package/lib/cjs/utils/is-redirect.js +26 -0
- package/lib/cjs/utils/is.js +47 -0
- package/lib/cjs/utils/multipart-parser.js +372 -0
- package/lib/cjs/utils/referrer.js +172 -0
- package/lib/esm/body.js +255 -0
- package/lib/esm/errors/abort-error.js +9 -0
- package/lib/esm/errors/base.js +17 -0
- package/lib/esm/errors/fetch-error.js +21 -0
- package/lib/esm/headers.js +202 -0
- package/lib/esm/index.js +224 -0
- package/lib/esm/request.js +281 -0
- package/lib/esm/response.js +133 -0
- package/lib/esm/types/index.js +1 -0
- package/lib/esm/types/system-error.js +1 -0
- package/lib/esm/utils/blob-from.js +101 -0
- package/lib/esm/utils/get-search.js +11 -0
- package/lib/esm/utils/is-redirect.js +7 -0
- package/lib/esm/utils/is.js +28 -0
- package/lib/esm/utils/multipart-parser.js +353 -0
- package/lib/esm/utils/referrer.js +153 -0
- package/package.json +53 -0
- package/src/body.ts +415 -0
- package/src/errors/abort-error.ts +10 -0
- package/src/errors/base.ts +20 -0
- package/src/errors/fetch-error.ts +26 -0
- package/src/headers.ts +279 -0
- package/src/index.spec.ts +13 -0
- package/src/index.ts +367 -0
- package/src/request.ts +396 -0
- package/src/response.ts +197 -0
- package/src/test.mts +6 -0
- package/src/types/index.ts +1 -0
- package/src/types/system-error.ts +11 -0
- package/src/utils/blob-from.ts +168 -0
- package/src/utils/get-search.ts +9 -0
- package/src/utils/is-redirect.ts +11 -0
- package/src/utils/is.ts +88 -0
- package/src/utils/multipart-parser.ts +448 -0
- package/src/utils/referrer.ts +350 -0
- package/test.gjs.js +34758 -0
- package/test.gjs.mjs +53177 -0
- package/test.node.js +1226 -0
- package/test.node.mjs +6294 -0
- package/tsconfig.json +19 -0
- package/tsconfig.types.json +8 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
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 response_exports = {};
|
|
29
|
+
__export(response_exports, {
|
|
30
|
+
Response: () => Response,
|
|
31
|
+
default: () => response_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(response_exports);
|
|
34
|
+
var import_glib_2 = __toESM(require("@girs/glib-2.0"), 1);
|
|
35
|
+
var import_gio_2 = __toESM(require("@girs/gio-2.0"), 1);
|
|
36
|
+
var import_headers = __toESM(require("./headers.js"), 1);
|
|
37
|
+
var import_body = __toESM(require("./body.js"), 1);
|
|
38
|
+
var import_is_redirect = require("./utils/is-redirect.js");
|
|
39
|
+
var import_url = require("@gjsify/deno-runtime/ext/url/00_url");
|
|
40
|
+
const INTERNALS = Symbol("Response internals");
|
|
41
|
+
class Response extends import_body.default {
|
|
42
|
+
[INTERNALS];
|
|
43
|
+
_inputStream = null;
|
|
44
|
+
constructor(body = null, options = {}) {
|
|
45
|
+
super(body, options);
|
|
46
|
+
const status = options.status != null ? options.status : 200;
|
|
47
|
+
const headers = new import_headers.default(options.headers);
|
|
48
|
+
if (body !== null && !headers.has("Content-Type")) {
|
|
49
|
+
const contentType = (0, import_body.extractContentType)(body, this);
|
|
50
|
+
if (contentType) {
|
|
51
|
+
headers.append("Content-Type", contentType);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this[INTERNALS] = {
|
|
55
|
+
type: "default",
|
|
56
|
+
url: options.url,
|
|
57
|
+
status,
|
|
58
|
+
statusText: options.statusText || "",
|
|
59
|
+
headers,
|
|
60
|
+
counter: options.counter,
|
|
61
|
+
highWaterMark: options.highWaterMark
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
get type() {
|
|
65
|
+
return this[INTERNALS].type;
|
|
66
|
+
}
|
|
67
|
+
get url() {
|
|
68
|
+
return this[INTERNALS].url || "";
|
|
69
|
+
}
|
|
70
|
+
get status() {
|
|
71
|
+
return this[INTERNALS].status;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Convenience property representing if the request ended normally
|
|
75
|
+
*/
|
|
76
|
+
get ok() {
|
|
77
|
+
return this[INTERNALS].status >= 200 && this[INTERNALS].status < 300;
|
|
78
|
+
}
|
|
79
|
+
get redirected() {
|
|
80
|
+
return this[INTERNALS].counter > 0;
|
|
81
|
+
}
|
|
82
|
+
get statusText() {
|
|
83
|
+
return this[INTERNALS].statusText;
|
|
84
|
+
}
|
|
85
|
+
get headers() {
|
|
86
|
+
return this[INTERNALS].headers;
|
|
87
|
+
}
|
|
88
|
+
get highWaterMark() {
|
|
89
|
+
return this[INTERNALS].highWaterMark;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Clone this response
|
|
93
|
+
*
|
|
94
|
+
* @return Response
|
|
95
|
+
*/
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
clone() {
|
|
98
|
+
return new Response((0, import_body.clone)(this, this.highWaterMark), {
|
|
99
|
+
type: this.type,
|
|
100
|
+
url: this.url,
|
|
101
|
+
status: this.status,
|
|
102
|
+
statusText: this.statusText,
|
|
103
|
+
headers: this.headers,
|
|
104
|
+
ok: this.ok,
|
|
105
|
+
redirected: this.redirected,
|
|
106
|
+
size: this.size,
|
|
107
|
+
highWaterMark: this.highWaterMark
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @param url The URL that the new response is to originate from.
|
|
112
|
+
* @param status An optional status code for the response (e.g., 302.)
|
|
113
|
+
* @returns A Response object.
|
|
114
|
+
*/
|
|
115
|
+
static redirect(url, status = 302) {
|
|
116
|
+
if (!(0, import_is_redirect.isRedirect)(status)) {
|
|
117
|
+
throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
|
|
118
|
+
}
|
|
119
|
+
return new Response(null, {
|
|
120
|
+
headers: {
|
|
121
|
+
location: new import_url.URL(url).toString()
|
|
122
|
+
},
|
|
123
|
+
status
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
static error() {
|
|
127
|
+
const response = new Response(null, { status: 0, statusText: "" });
|
|
128
|
+
response[INTERNALS].type = "error";
|
|
129
|
+
return response;
|
|
130
|
+
}
|
|
131
|
+
get [Symbol.toStringTag]() {
|
|
132
|
+
return "Response";
|
|
133
|
+
}
|
|
134
|
+
async text() {
|
|
135
|
+
if (!this._inputStream) {
|
|
136
|
+
return super.text();
|
|
137
|
+
}
|
|
138
|
+
const outputStream = import_gio_2.default.MemoryOutputStream.new_resizable();
|
|
139
|
+
await new Promise((resolve, reject) => {
|
|
140
|
+
outputStream.splice_async(this._inputStream, import_gio_2.default.OutputStreamSpliceFlags.CLOSE_TARGET | import_gio_2.default.OutputStreamSpliceFlags.CLOSE_SOURCE, import_glib_2.default.PRIORITY_DEFAULT, null, (self, res) => {
|
|
141
|
+
try {
|
|
142
|
+
resolve(outputStream.splice_finish(res));
|
|
143
|
+
} catch (error) {
|
|
144
|
+
reject(error);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
const bytes = outputStream.steal_as_bytes();
|
|
149
|
+
return new TextDecoder().decode(bytes.toArray());
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
Object.defineProperties(Response.prototype, {
|
|
153
|
+
type: { enumerable: true },
|
|
154
|
+
url: { enumerable: true },
|
|
155
|
+
status: { enumerable: true },
|
|
156
|
+
ok: { enumerable: true },
|
|
157
|
+
redirected: { enumerable: true },
|
|
158
|
+
statusText: { enumerable: true },
|
|
159
|
+
headers: { enumerable: true },
|
|
160
|
+
clone: { enumerable: true }
|
|
161
|
+
});
|
|
162
|
+
var response_default = Response;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
__reExport(types_exports, require("./system-error.js"), module.exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var system_error_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(system_error_exports);
|
|
16
|
+
;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
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;
|
|
48
|
+
let i = 0, tempDir, registry;
|
|
49
|
+
const blobFromSync = (path, type) => fromBlob((0, import_node_fs.statSync)(path), path, type);
|
|
50
|
+
const blobFrom = (path, type) => stat(path).then((stat2) => fromBlob(stat2, path, type));
|
|
51
|
+
const fileFrom = (path, type) => stat(path).then((stat2) => fromFile(stat2, path, type));
|
|
52
|
+
const fileFromSync = (path, type) => fromFile((0, import_node_fs.statSync)(path), path, type);
|
|
53
|
+
const fromBlob = (stat2, path, type = "") => new import_file.Blob([new BlobDataItem({
|
|
54
|
+
path,
|
|
55
|
+
size: stat2.size,
|
|
56
|
+
lastModified: stat2.mtimeMs,
|
|
57
|
+
start: 0
|
|
58
|
+
})], { type });
|
|
59
|
+
const fromFile = (stat2, path, type = "") => new import_file.File([new BlobDataItem({
|
|
60
|
+
path,
|
|
61
|
+
size: stat2.size,
|
|
62
|
+
lastModified: stat2.mtimeMs,
|
|
63
|
+
start: 0
|
|
64
|
+
})], (0, import_node_path.basename)(path), { type, lastModified: stat2.mtimeMs });
|
|
65
|
+
const createTemporaryBlob = async (data, { signal, type } = {}) => {
|
|
66
|
+
registry = registry || new FinalizationRegistry(import_node_fs.promises.unlink);
|
|
67
|
+
tempDir = tempDir || await mkdtemp((0, import_node_fs.realpathSync)((0, import_node_os.tmpdir)()) + import_node_path.sep);
|
|
68
|
+
const id = `${i++}`;
|
|
69
|
+
const destination = (0, import_node_path.join)(tempDir, id);
|
|
70
|
+
if (data instanceof ArrayBuffer)
|
|
71
|
+
data = new Uint8Array(data);
|
|
72
|
+
await import_node_fs.promises.writeFile(destination, data, { signal });
|
|
73
|
+
const blob = await blobFrom(destination, type);
|
|
74
|
+
registry.register(blob, destination);
|
|
75
|
+
return blob;
|
|
76
|
+
};
|
|
77
|
+
const createTemporaryFile = async (data, name, opts) => {
|
|
78
|
+
const blob = await createTemporaryBlob(data);
|
|
79
|
+
return new import_file.File([blob], name, opts);
|
|
80
|
+
};
|
|
81
|
+
class BlobDataItem {
|
|
82
|
+
#path;
|
|
83
|
+
#start;
|
|
84
|
+
size;
|
|
85
|
+
lastModified;
|
|
86
|
+
originalSize;
|
|
87
|
+
constructor(options) {
|
|
88
|
+
this.#path = options.path;
|
|
89
|
+
this.#start = options.start;
|
|
90
|
+
this.size = options.size;
|
|
91
|
+
this.lastModified = options.lastModified;
|
|
92
|
+
this.originalSize = options.originalSize === void 0 ? options.size : options.originalSize;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Slicing arguments is first validated and formatted
|
|
96
|
+
* to not be out of range by Blob.prototype.slice
|
|
97
|
+
*/
|
|
98
|
+
slice(start, end) {
|
|
99
|
+
return new BlobDataItem({
|
|
100
|
+
path: this.#path,
|
|
101
|
+
lastModified: this.lastModified,
|
|
102
|
+
originalSize: this.originalSize,
|
|
103
|
+
size: end - start,
|
|
104
|
+
start: this.#start + start
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async *stream() {
|
|
108
|
+
const { mtimeMs, size } = await stat(this.#path);
|
|
109
|
+
if (mtimeMs > this.lastModified || this.originalSize !== size) {
|
|
110
|
+
throw new import_dom_exception.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
|
+
}
|
|
112
|
+
yield* (0, import_node_fs.createReadStream)(this.#path, {
|
|
113
|
+
start: this.#start,
|
|
114
|
+
end: this.#start + this.size - 1
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
get [Symbol.toStringTag]() {
|
|
118
|
+
return "Blob";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
import_node_process.default.once("exit", () => {
|
|
122
|
+
tempDir && (0, import_node_fs.rmdirSync)(tempDir, { recursive: true });
|
|
123
|
+
});
|
|
124
|
+
var blob_from_default = blobFromSync;
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
const getSearch = (parsedURL) => {
|
|
24
|
+
if (parsedURL.search) {
|
|
25
|
+
return parsedURL.search;
|
|
26
|
+
}
|
|
27
|
+
const lastOffset = parsedURL.href.length - 1;
|
|
28
|
+
const hash = parsedURL.hash || (parsedURL.href[lastOffset] === "#" ? "#" : "");
|
|
29
|
+
return parsedURL.href[lastOffset - hash.length] === "?" ? "?" : "";
|
|
30
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const redirectStatus = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
24
|
+
const isRedirect = (code) => {
|
|
25
|
+
return redirectStatus.has(code);
|
|
26
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
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_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");
|
|
28
|
+
const NAME = Symbol.toStringTag;
|
|
29
|
+
const isURLSearchParameters = (object) => {
|
|
30
|
+
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";
|
|
31
|
+
};
|
|
32
|
+
const isBlob = (value) => {
|
|
33
|
+
return value && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.constructor === "function" && /^(Blob|File)$/.test(value[NAME]);
|
|
34
|
+
};
|
|
35
|
+
const isAbortSignal = (object) => {
|
|
36
|
+
return typeof object === "object" && (object[NAME] === "AbortSignal" || object[NAME] === "EventTarget");
|
|
37
|
+
};
|
|
38
|
+
const isDomainOrSubdomain = (destination, original) => {
|
|
39
|
+
const orig = new import_url.URL(original).hostname;
|
|
40
|
+
const dest = new import_url.URL(destination).hostname;
|
|
41
|
+
return orig === dest || orig.endsWith(`.${dest}`);
|
|
42
|
+
};
|
|
43
|
+
const isSameProtocol = (destination, original) => {
|
|
44
|
+
const orig = new import_url.URL(original).protocol;
|
|
45
|
+
const dest = new import_url.URL(destination).protocol;
|
|
46
|
+
return orig === dest;
|
|
47
|
+
};
|