@delexec/ops 0.1.3 → 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 response = await fetch(new URL(pathname, baseUrl), {
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 response = await fetch(new URL(pathname, baseUrl), {
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 response = await fetch(new URL(pathname, baseUrl), {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delexec/ops",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Unified operator CLI for delegated execution clients",
5
5
  "type": "module",
6
6
  "bin": {
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 response = await fetch(new URL(pathname, baseUrl), {
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
- return new URL(pathname, `${baseUrl}/`).toString();
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) {