ipx 0.9.1 → 0.9.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.
|
@@ -116,12 +116,12 @@ const createHTTPSource = (options) => {
|
|
|
116
116
|
}
|
|
117
117
|
const hosts = domains.map((domain) => ufo.parseURL(domain, "https://").host);
|
|
118
118
|
return async (id, reqOptions) => {
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
119
|
+
const url = new URL(id);
|
|
120
|
+
if (!url.hostname) {
|
|
121
121
|
throw createError("Hostname is missing: " + id, 403);
|
|
122
122
|
}
|
|
123
|
-
if (!reqOptions?.bypassDomain && !hosts.find((host) =>
|
|
124
|
-
throw createError("Forbidden host: " +
|
|
123
|
+
if (!reqOptions?.bypassDomain && !hosts.find((host) => url.hostname === host)) {
|
|
124
|
+
throw createError("Forbidden host: " + url.hostname, 403);
|
|
125
125
|
}
|
|
126
126
|
const response = await ohmyfetch.fetch(id, {
|
|
127
127
|
agent: id.startsWith("https") ? httpsAgent : httpAgent
|
|
@@ -104,12 +104,12 @@ const createHTTPSource = (options) => {
|
|
|
104
104
|
}
|
|
105
105
|
const hosts = domains.map((domain) => parseURL(domain, "https://").host);
|
|
106
106
|
return async (id, reqOptions) => {
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
107
|
+
const url = new URL(id);
|
|
108
|
+
if (!url.hostname) {
|
|
109
109
|
throw createError("Hostname is missing: " + id, 403);
|
|
110
110
|
}
|
|
111
|
-
if (!reqOptions?.bypassDomain && !hosts.find((host) =>
|
|
112
|
-
throw createError("Forbidden host: " +
|
|
111
|
+
if (!reqOptions?.bypassDomain && !hosts.find((host) => url.hostname === host)) {
|
|
112
|
+
throw createError("Forbidden host: " + url.hostname, 403);
|
|
113
113
|
}
|
|
114
114
|
const response = await fetch(id, {
|
|
115
115
|
agent: id.startsWith("https") ? httpsAgent : httpAgent
|