@fedify/vocab-runtime 2.2.17 → 2.2.18
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/deno.json +1 -1
- package/dist/mod.cjs +4 -2
- package/dist/mod.js +4 -2
- package/dist/tests/{body-Bxt2m_JA.cjs → body-CaJBg0tr.cjs} +1 -1
- package/dist/tests/{body-DfFCA-Lo.mjs → body-CbvYxP3V.mjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/decimal.test.cjs +1 -1
- package/dist/tests/decimal.test.mjs +1 -1
- package/dist/tests/{docloader-B2YL1dZE.mjs → docloader-jQMjHIRI.mjs} +5 -3
- package/dist/tests/{docloader-bp9CfxxP.cjs → docloader-k2T5kUlV.cjs} +5 -3
- package/dist/tests/docloader.test.cjs +50 -2
- package/dist/tests/docloader.test.mjs +50 -2
- package/dist/tests/{request-BI4kDbBx.mjs → request-BE7XIrGw.mjs} +1 -1
- package/dist/tests/{request-CHH9A9oL.cjs → request-BngWcP0t.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/package.json +1 -1
- package/src/docloader.test.ts +90 -0
- package/src/docloader.ts +5 -1
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -4593,7 +4593,7 @@ const preloadedContexts = {
|
|
|
4593
4593
|
//#endregion
|
|
4594
4594
|
//#region deno.json
|
|
4595
4595
|
var name = "@fedify/vocab-runtime";
|
|
4596
|
-
var version = "2.2.
|
|
4596
|
+
var version = "2.2.18";
|
|
4597
4597
|
//#endregion
|
|
4598
4598
|
//#region src/request.ts
|
|
4599
4599
|
/**
|
|
@@ -5254,7 +5254,9 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5254
5254
|
const maximumRedirection = maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
|
5255
5255
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
5256
5256
|
options?.signal?.throwIfAborted();
|
|
5257
|
-
const
|
|
5257
|
+
const parsedUrl = new URL(url);
|
|
5258
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
5259
|
+
const currentUrl = parsedUrl.href;
|
|
5258
5260
|
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
5259
5261
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
5260
5262
|
return {
|
package/dist/mod.js
CHANGED
|
@@ -4588,7 +4588,7 @@ const preloadedContexts = {
|
|
|
4588
4588
|
//#endregion
|
|
4589
4589
|
//#region deno.json
|
|
4590
4590
|
var name = "@fedify/vocab-runtime";
|
|
4591
|
-
var version = "2.2.
|
|
4591
|
+
var version = "2.2.18";
|
|
4592
4592
|
//#endregion
|
|
4593
4593
|
//#region src/request.ts
|
|
4594
4594
|
/**
|
|
@@ -5249,7 +5249,9 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5249
5249
|
const maximumRedirection = maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
|
5250
5250
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
5251
5251
|
options?.signal?.throwIfAborted();
|
|
5252
|
-
const
|
|
5252
|
+
const parsedUrl = new URL(url);
|
|
5253
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
5254
|
+
const currentUrl = parsedUrl.href;
|
|
5253
5255
|
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
5254
5256
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
5255
5257
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BngWcP0t.cjs");
|
|
3
3
|
let _logtape_logtape = require("@logtape/logtape");
|
|
4
4
|
//#region src/body.ts
|
|
5
5
|
/** Decoded JSON body limit: 16 MiB. @internal */
|
package/dist/tests/body.test.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_body = require("./body-
|
|
2
|
+
const require_body = require("./body-CaJBg0tr.cjs");
|
|
3
3
|
let node_assert_strict = require("node:assert/strict");
|
|
4
4
|
let node_test = require("node:test");
|
|
5
5
|
let node_zlib = require("node:zlib");
|
package/dist/tests/body.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as readBoundedText, t as BodyTooLargeError } from "./body-
|
|
1
|
+
import { r as readBoundedText, t as BodyTooLargeError } from "./body-CbvYxP3V.mjs";
|
|
2
2
|
import { deepStrictEqual, ok, rejects } from "node:assert/strict";
|
|
3
3
|
import { test } from "node:test";
|
|
4
4
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-
|
|
2
|
-
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-
|
|
1
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-BE7XIrGw.mjs";
|
|
2
|
+
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-CbvYxP3V.mjs";
|
|
3
3
|
import { t as HttpHeaderLink } from "./link-CYszIegt.mjs";
|
|
4
4
|
import { o as validatePublicUrl, t as UrlError } from "./url-3fyJuqC0.mjs";
|
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -4704,7 +4704,9 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4704
4704
|
const maximumRedirection = maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
|
4705
4705
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
4706
4706
|
options?.signal?.throwIfAborted();
|
|
4707
|
-
const
|
|
4707
|
+
const parsedUrl = new URL(url);
|
|
4708
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
4709
|
+
const currentUrl = parsedUrl.href;
|
|
4708
4710
|
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
4709
4711
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
4710
4712
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
3
|
-
const require_body = require("./body-
|
|
2
|
+
const require_request = require("./request-BngWcP0t.cjs");
|
|
3
|
+
const require_body = require("./body-CaJBg0tr.cjs");
|
|
4
4
|
const require_link = require("./link-qDTmjPw_.cjs");
|
|
5
5
|
const require_url = require("./url-vZTgkIZg.cjs");
|
|
6
6
|
let _logtape_logtape = require("@logtape/logtape");
|
|
@@ -4705,7 +4705,9 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4705
4705
|
const maximumRedirection = maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
|
4706
4706
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
4707
4707
|
options?.signal?.throwIfAborted();
|
|
4708
|
-
const
|
|
4708
|
+
const parsedUrl = new URL(url);
|
|
4709
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new require_url.UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
4710
|
+
const currentUrl = parsedUrl.href;
|
|
4709
4711
|
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
4710
4712
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
4711
4713
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
3
|
-
const require_docloader = require("./docloader-
|
|
2
|
+
const require_request = require("./request-BngWcP0t.cjs");
|
|
3
|
+
const require_docloader = require("./docloader-k2T5kUlV.cjs");
|
|
4
4
|
const require_url = require("./url-vZTgkIZg.cjs");
|
|
5
5
|
let node_zlib = require("node:zlib");
|
|
6
6
|
let _logtape_logtape = require("@logtape/logtape");
|
|
@@ -2009,4 +2009,52 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
2009
2009
|
esm_default.hardReset();
|
|
2010
2010
|
}
|
|
2011
2011
|
});
|
|
2012
|
+
const unsupportedUrls = [
|
|
2013
|
+
"ftp://example.com/collection",
|
|
2014
|
+
"file:///collection",
|
|
2015
|
+
`data:application/ld+json,${encodeURIComponent(JSON.stringify({ id: "https://example.com/data" }))}`
|
|
2016
|
+
];
|
|
2017
|
+
function isUnsupportedProtocolError(error, url) {
|
|
2018
|
+
return error instanceof require_url.UrlError && error.message === `Unsupported protocol: ${new URL(url).protocol}` && error.reason === "disallowed";
|
|
2019
|
+
}
|
|
2020
|
+
async function withFetchStub(respond, callback) {
|
|
2021
|
+
const fetched = [];
|
|
2022
|
+
const originalFetch = globalThis.fetch;
|
|
2023
|
+
globalThis.fetch = (input) => {
|
|
2024
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
2025
|
+
fetched.push(url);
|
|
2026
|
+
return Promise.resolve(respond(url));
|
|
2027
|
+
};
|
|
2028
|
+
try {
|
|
2029
|
+
await callback(fetched);
|
|
2030
|
+
} finally {
|
|
2031
|
+
globalThis.fetch = originalFetch;
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
for (const url of unsupportedUrls) {
|
|
2035
|
+
const scheme = new URL(url).protocol;
|
|
2036
|
+
(0, _fedify_fixture.test)(`getDocumentLoader() rejects ${scheme} URLs with private addresses allowed before fetching`, async () => {
|
|
2037
|
+
await withFetchStub(() => Response.json({}), async (fetched) => {
|
|
2038
|
+
await (0, node_assert.rejects)(require_docloader.getDocumentLoader({ allowPrivateAddress: true })(url), (e) => isUnsupportedProtocolError(e, url));
|
|
2039
|
+
(0, node_assert.deepStrictEqual)(fetched, []);
|
|
2040
|
+
});
|
|
2041
|
+
});
|
|
2042
|
+
(0, _fedify_fixture.test)(`getDocumentLoader() rejects redirects to ${scheme} URLs with private addresses allowed`, async () => {
|
|
2043
|
+
const start = "https://example.com/redirect-to-unsupported";
|
|
2044
|
+
await withFetchStub(() => Response.redirect(url, 302), async (fetched) => {
|
|
2045
|
+
await (0, node_assert.rejects)(require_docloader.getDocumentLoader({ allowPrivateAddress: true })(start), (e) => isUnsupportedProtocolError(e, url));
|
|
2046
|
+
(0, node_assert.deepStrictEqual)(fetched, [start]);
|
|
2047
|
+
});
|
|
2048
|
+
});
|
|
2049
|
+
for (const html of [false, true]) (0, _fedify_fixture.test)(`getDocumentLoader() rejects ${html ? "HTML" : "Link header"} alternates to ${scheme} URLs with private addresses allowed`, async () => {
|
|
2050
|
+
const start = "https://example.com/alternate-to-unsupported";
|
|
2051
|
+
await withFetchStub(() => html ? new Response(`<link rel="alternate" type="application/activity+json" href="${url}">`, { headers: { "Content-Type": "text/html" } }) : new Response("", { headers: {
|
|
2052
|
+
"Content-Type": "text/plain",
|
|
2053
|
+
Link: `<${url}>; rel="alternate"; type="application/activity+json"`
|
|
2054
|
+
} }), async (fetched) => {
|
|
2055
|
+
await (0, node_assert.rejects)(require_docloader.getDocumentLoader({ allowPrivateAddress: true })(start), (e) => isUnsupportedProtocolError(e, url));
|
|
2056
|
+
(0, node_assert.deepStrictEqual)(fetched, [start]);
|
|
2057
|
+
});
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2012
2060
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as FetchError } from "./request-
|
|
2
|
-
import { i as cid_v1_default, n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-
|
|
1
|
+
import { t as FetchError } from "./request-BE7XIrGw.mjs";
|
|
2
|
+
import { i as cid_v1_default, n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-jQMjHIRI.mjs";
|
|
3
3
|
import { t as UrlError } from "./url-3fyJuqC0.mjs";
|
|
4
4
|
import { gzipSync } from "node:zlib";
|
|
5
5
|
import { configure, reset } from "@logtape/logtape";
|
|
@@ -2026,5 +2026,53 @@ test("getDocumentLoader() rejects cancellation before fetching", async () => {
|
|
|
2026
2026
|
esm_default.hardReset();
|
|
2027
2027
|
}
|
|
2028
2028
|
});
|
|
2029
|
+
const unsupportedUrls = [
|
|
2030
|
+
"ftp://example.com/collection",
|
|
2031
|
+
"file:///collection",
|
|
2032
|
+
`data:application/ld+json,${encodeURIComponent(JSON.stringify({ id: "https://example.com/data" }))}`
|
|
2033
|
+
];
|
|
2034
|
+
function isUnsupportedProtocolError(error, url) {
|
|
2035
|
+
return error instanceof UrlError && error.message === `Unsupported protocol: ${new URL(url).protocol}` && error.reason === "disallowed";
|
|
2036
|
+
}
|
|
2037
|
+
async function withFetchStub(respond, callback) {
|
|
2038
|
+
const fetched = [];
|
|
2039
|
+
const originalFetch = globalThis.fetch;
|
|
2040
|
+
globalThis.fetch = (input) => {
|
|
2041
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
2042
|
+
fetched.push(url);
|
|
2043
|
+
return Promise.resolve(respond(url));
|
|
2044
|
+
};
|
|
2045
|
+
try {
|
|
2046
|
+
await callback(fetched);
|
|
2047
|
+
} finally {
|
|
2048
|
+
globalThis.fetch = originalFetch;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
for (const url of unsupportedUrls) {
|
|
2052
|
+
const scheme = new URL(url).protocol;
|
|
2053
|
+
test(`getDocumentLoader() rejects ${scheme} URLs with private addresses allowed before fetching`, async () => {
|
|
2054
|
+
await withFetchStub(() => Response.json({}), async (fetched) => {
|
|
2055
|
+
await rejects(getDocumentLoader({ allowPrivateAddress: true })(url), (e) => isUnsupportedProtocolError(e, url));
|
|
2056
|
+
deepStrictEqual(fetched, []);
|
|
2057
|
+
});
|
|
2058
|
+
});
|
|
2059
|
+
test(`getDocumentLoader() rejects redirects to ${scheme} URLs with private addresses allowed`, async () => {
|
|
2060
|
+
const start = "https://example.com/redirect-to-unsupported";
|
|
2061
|
+
await withFetchStub(() => Response.redirect(url, 302), async (fetched) => {
|
|
2062
|
+
await rejects(getDocumentLoader({ allowPrivateAddress: true })(start), (e) => isUnsupportedProtocolError(e, url));
|
|
2063
|
+
deepStrictEqual(fetched, [start]);
|
|
2064
|
+
});
|
|
2065
|
+
});
|
|
2066
|
+
for (const html of [false, true]) test(`getDocumentLoader() rejects ${html ? "HTML" : "Link header"} alternates to ${scheme} URLs with private addresses allowed`, async () => {
|
|
2067
|
+
const start = "https://example.com/alternate-to-unsupported";
|
|
2068
|
+
await withFetchStub(() => html ? new Response(`<link rel="alternate" type="application/activity+json" href="${url}">`, { headers: { "Content-Type": "text/html" } }) : new Response("", { headers: {
|
|
2069
|
+
"Content-Type": "text/plain",
|
|
2070
|
+
Link: `<${url}>; rel="alternate"; type="application/activity+json"`
|
|
2071
|
+
} }), async (fetched) => {
|
|
2072
|
+
await rejects(getDocumentLoader({ allowPrivateAddress: true })(start), (e) => isUnsupportedProtocolError(e, url));
|
|
2073
|
+
deepStrictEqual(fetched, [start]);
|
|
2074
|
+
});
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2029
2077
|
//#endregion
|
|
2030
2078
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BngWcP0t.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as version, r as getUserAgent } from "./request-
|
|
1
|
+
import { o as version, r as getUserAgent } from "./request-BE7XIrGw.mjs";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { deepStrictEqual } from "node:assert";
|
package/package.json
CHANGED
package/src/docloader.test.ts
CHANGED
|
@@ -1103,3 +1103,93 @@ test("getDocumentLoader() rejects cancellation before fetching", async () => {
|
|
|
1103
1103
|
fetchMock.hardReset();
|
|
1104
1104
|
}
|
|
1105
1105
|
});
|
|
1106
|
+
|
|
1107
|
+
const unsupportedUrls = [
|
|
1108
|
+
"ftp://example.com/collection",
|
|
1109
|
+
"file:///collection",
|
|
1110
|
+
`data:application/ld+json,${
|
|
1111
|
+
encodeURIComponent(JSON.stringify({ id: "https://example.com/data" }))
|
|
1112
|
+
}`,
|
|
1113
|
+
];
|
|
1114
|
+
|
|
1115
|
+
function isUnsupportedProtocolError(error: unknown, url: string): boolean {
|
|
1116
|
+
return error instanceof UrlError &&
|
|
1117
|
+
error.message === `Unsupported protocol: ${new URL(url).protocol}` &&
|
|
1118
|
+
error.reason === "disallowed";
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
async function withFetchStub(
|
|
1122
|
+
respond: (url: string) => Response,
|
|
1123
|
+
callback: (fetched: string[]) => Promise<void>,
|
|
1124
|
+
): Promise<void> {
|
|
1125
|
+
const fetched: string[] = [];
|
|
1126
|
+
const originalFetch = globalThis.fetch;
|
|
1127
|
+
globalThis.fetch = (input: RequestInfo | URL) => {
|
|
1128
|
+
const url = input instanceof Request ? input.url : String(input);
|
|
1129
|
+
fetched.push(url);
|
|
1130
|
+
return Promise.resolve(respond(url));
|
|
1131
|
+
};
|
|
1132
|
+
try {
|
|
1133
|
+
await callback(fetched);
|
|
1134
|
+
} finally {
|
|
1135
|
+
globalThis.fetch = originalFetch;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
for (const url of unsupportedUrls) {
|
|
1140
|
+
const scheme = new URL(url).protocol;
|
|
1141
|
+
|
|
1142
|
+
test(`getDocumentLoader() rejects ${scheme} URLs with private addresses allowed before fetching`, async () => {
|
|
1143
|
+
await withFetchStub(() => Response.json({}), async (fetched) => {
|
|
1144
|
+
await rejects(
|
|
1145
|
+
getDocumentLoader({ allowPrivateAddress: true })(url),
|
|
1146
|
+
(e) => isUnsupportedProtocolError(e, url),
|
|
1147
|
+
);
|
|
1148
|
+
deepStrictEqual(fetched, []);
|
|
1149
|
+
});
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
test(`getDocumentLoader() rejects redirects to ${scheme} URLs with private addresses allowed`, async () => {
|
|
1153
|
+
const start = "https://example.com/redirect-to-unsupported";
|
|
1154
|
+
await withFetchStub(() => Response.redirect(url, 302), async (fetched) => {
|
|
1155
|
+
await rejects(
|
|
1156
|
+
getDocumentLoader({ allowPrivateAddress: true })(start),
|
|
1157
|
+
(e) => isUnsupportedProtocolError(e, url),
|
|
1158
|
+
);
|
|
1159
|
+
deepStrictEqual(fetched, [start]);
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
for (const html of [false, true]) {
|
|
1164
|
+
test(
|
|
1165
|
+
`getDocumentLoader() rejects ${
|
|
1166
|
+
html ? "HTML" : "Link header"
|
|
1167
|
+
} alternates to ${scheme} URLs with private addresses allowed`,
|
|
1168
|
+
async () => {
|
|
1169
|
+
const start = "https://example.com/alternate-to-unsupported";
|
|
1170
|
+
await withFetchStub(
|
|
1171
|
+
() =>
|
|
1172
|
+
html
|
|
1173
|
+
? new Response(
|
|
1174
|
+
`<link rel="alternate" type="application/activity+json" href="${url}">`,
|
|
1175
|
+
{ headers: { "Content-Type": "text/html" } },
|
|
1176
|
+
)
|
|
1177
|
+
: new Response("", {
|
|
1178
|
+
headers: {
|
|
1179
|
+
"Content-Type": "text/plain",
|
|
1180
|
+
Link:
|
|
1181
|
+
`<${url}>; rel="alternate"; type="application/activity+json"`,
|
|
1182
|
+
},
|
|
1183
|
+
}),
|
|
1184
|
+
async (fetched) => {
|
|
1185
|
+
await rejects(
|
|
1186
|
+
getDocumentLoader({ allowPrivateAddress: true })(start),
|
|
1187
|
+
(e) => isUnsupportedProtocolError(e, url),
|
|
1188
|
+
);
|
|
1189
|
+
deepStrictEqual(fetched, [start]);
|
|
1190
|
+
},
|
|
1191
|
+
);
|
|
1192
|
+
},
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
package/src/docloader.ts
CHANGED
|
@@ -311,7 +311,11 @@ export function getDocumentLoader(
|
|
|
311
311
|
visited = new Set<string>(),
|
|
312
312
|
): Promise<RemoteDocument> {
|
|
313
313
|
options?.signal?.throwIfAborted();
|
|
314
|
-
const
|
|
314
|
+
const parsedUrl = new URL(url);
|
|
315
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
316
|
+
throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
|
|
317
|
+
}
|
|
318
|
+
const currentUrl = parsedUrl.href;
|
|
315
319
|
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
316
320
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
317
321
|
return {
|