@delexec/ops 0.1.2 → 0.1.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.
|
@@ -47,7 +47,9 @@ function sendError(res, statusCode, code, message, { retryable, ...extra } = {})
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function requestJson(baseUrl, pathname, { method = "GET", headers = {}, body } = {}) {
|
|
50
|
-
const
|
|
50
|
+
const base = String(baseUrl || "").endsWith("/") ? String(baseUrl) : `${baseUrl}/`;
|
|
51
|
+
const relativePath = String(pathname || "").replace(/^\/+/, "");
|
|
52
|
+
const response = await fetch(new URL(relativePath, base), {
|
|
51
53
|
method,
|
|
52
54
|
headers: {
|
|
53
55
|
...headers,
|
|
@@ -49,7 +49,9 @@ function sendError(res, statusCode, code, message, { retryable, ...extra } = {})
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async function postJson(baseUrl, pathname, { method = "POST", headers = {}, body } = {}) {
|
|
52
|
-
const
|
|
52
|
+
const base = String(baseUrl || "").endsWith("/") ? String(baseUrl) : `${baseUrl}/`;
|
|
53
|
+
const relativePath = String(pathname || "").replace(/^\/+/, "");
|
|
54
|
+
const response = await fetch(new URL(relativePath, base), {
|
|
53
55
|
method,
|
|
54
56
|
headers: {
|
|
55
57
|
"content-type": "application/json; charset=utf-8",
|
|
@@ -29,7 +29,9 @@ function resolveReceiver(target) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async function requestJson(baseUrl, pathname, { method = "GET", body } = {}) {
|
|
32
|
-
const
|
|
32
|
+
const base = String(baseUrl || "").endsWith("/") ? String(baseUrl) : `${baseUrl}/`;
|
|
33
|
+
const relativePath = String(pathname || "").replace(/^\/+/, "");
|
|
34
|
+
const response = await fetch(new URL(relativePath, base), {
|
|
33
35
|
method,
|
|
34
36
|
headers: body === undefined ? undefined : { "content-type": "application/json; charset=utf-8" },
|
|
35
37
|
body: body === undefined ? undefined : JSON.stringify(body)
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -151,7 +151,9 @@ function sanitizeIdSegment(value) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
async function requestJson(baseUrl, pathname, { method = "GET", headers = {}, body } = {}) {
|
|
154
|
-
const
|
|
154
|
+
const base = String(baseUrl || "").endsWith("/") ? String(baseUrl) : `${baseUrl}/`;
|
|
155
|
+
const relativePath = String(pathname || "").replace(/^\/+/, "");
|
|
156
|
+
const response = await fetch(new URL(relativePath, base), {
|
|
155
157
|
method,
|
|
156
158
|
headers: {
|
|
157
159
|
...headers,
|
package/src/supervisor.js
CHANGED
|
@@ -122,7 +122,9 @@ function parseJsonBody(req) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
async function requestJson(baseUrl, pathname, { method = "GET", headers = {}, body } = {}) {
|
|
125
|
-
const
|
|
125
|
+
const base = String(baseUrl || "").endsWith("/") ? String(baseUrl) : `${baseUrl}/`;
|
|
126
|
+
const relativePath = String(pathname || "").replace(/^\/+/, "");
|
|
127
|
+
const response = await fetch(new URL(relativePath, base), {
|
|
126
128
|
method,
|
|
127
129
|
headers: {
|
|
128
130
|
...headers,
|
|
@@ -142,7 +144,9 @@ function processBaseUrl(port) {
|
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
function appendPath(baseUrl, pathname) {
|
|
145
|
-
|
|
147
|
+
const base = String(baseUrl || "").endsWith("/") ? String(baseUrl) : `${baseUrl}/`;
|
|
148
|
+
const relativePath = String(pathname || "").replace(/^\/+/, "");
|
|
149
|
+
return new URL(relativePath, base).toString();
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
function parseJsonArrayEnv(value) {
|