ipx 0.9.7 → 0.9.8
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.
|
@@ -120,18 +120,18 @@ function isValidPath(fp) {
|
|
|
120
120
|
const createHTTPSource = (options) => {
|
|
121
121
|
const httpsAgent = new https__default.Agent({ keepAlive: true });
|
|
122
122
|
const httpAgent = new http__default.Agent({ keepAlive: true });
|
|
123
|
-
let
|
|
124
|
-
if (typeof
|
|
125
|
-
|
|
123
|
+
let _domains = options.domains || [];
|
|
124
|
+
if (typeof _domains === "string") {
|
|
125
|
+
_domains = _domains.split(",").map((s) => s.trim());
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const domains = _domains.map((d) => new URL(d).hostname || new URL("http://" + d).hostname).filter(Boolean);
|
|
128
128
|
return async (id, reqOptions) => {
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
129
|
+
const hostname = new URL(id).hostname;
|
|
130
|
+
if (!hostname) {
|
|
131
131
|
throw createError("Hostname is missing", 403, id);
|
|
132
132
|
}
|
|
133
|
-
if (!reqOptions?.bypassDomain && !
|
|
134
|
-
throw createError("Forbidden host", 403,
|
|
133
|
+
if (!reqOptions?.bypassDomain && !domains.find((domain) => hostname === domain)) {
|
|
134
|
+
throw createError("Forbidden host", 403, hostname);
|
|
135
135
|
}
|
|
136
136
|
const response = await ohmyfetch.fetch(id, {
|
|
137
137
|
agent: id.startsWith("https") ? httpsAgent : httpAgent,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import defu from 'defu';
|
|
2
2
|
import { imageMeta } from 'image-meta';
|
|
3
|
-
import {
|
|
3
|
+
import { withLeadingSlash, hasProtocol, joinURL, decode } from 'ufo';
|
|
4
4
|
import { promises } from 'fs';
|
|
5
5
|
import { resolve, join, parse } from 'pathe';
|
|
6
6
|
import http from 'http';
|
|
@@ -109,18 +109,18 @@ function isValidPath(fp) {
|
|
|
109
109
|
const createHTTPSource = (options) => {
|
|
110
110
|
const httpsAgent = new https.Agent({ keepAlive: true });
|
|
111
111
|
const httpAgent = new http.Agent({ keepAlive: true });
|
|
112
|
-
let
|
|
113
|
-
if (typeof
|
|
114
|
-
|
|
112
|
+
let _domains = options.domains || [];
|
|
113
|
+
if (typeof _domains === "string") {
|
|
114
|
+
_domains = _domains.split(",").map((s) => s.trim());
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const domains = _domains.map((d) => new URL(d).hostname || new URL("http://" + d).hostname).filter(Boolean);
|
|
117
117
|
return async (id, reqOptions) => {
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
118
|
+
const hostname = new URL(id).hostname;
|
|
119
|
+
if (!hostname) {
|
|
120
120
|
throw createError("Hostname is missing", 403, id);
|
|
121
121
|
}
|
|
122
|
-
if (!reqOptions?.bypassDomain && !
|
|
123
|
-
throw createError("Forbidden host", 403,
|
|
122
|
+
if (!reqOptions?.bypassDomain && !domains.find((domain) => hostname === domain)) {
|
|
123
|
+
throw createError("Forbidden host", 403, hostname);
|
|
124
124
|
}
|
|
125
125
|
const response = await fetch(id, {
|
|
126
126
|
agent: id.startsWith("https") ? httpsAgent : httpAgent,
|