@verii/http-client 1.1.0-pre.1762210020 → 1.1.0-pre.1762240520

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/client.js +10 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verii/http-client",
3
- "version": "1.1.0-pre.1762210020",
3
+ "version": "1.1.0-pre.1762240520",
4
4
  "description": "HTTP client for Verii network",
5
5
  "repository": "https://github.com/LFDT-Verii/core",
6
6
  "main": "index.js",
@@ -33,7 +33,7 @@
33
33
  "eslint-plugin-prefer-arrow-functions": "3.9.1",
34
34
  "eslint-plugin-prettier": "4.2.5",
35
35
  "eslint-watch": "7.0.0",
36
- "expect": "29.7.0",
36
+ "expect": "30.2.0",
37
37
  "nodemon": "3.1.10",
38
38
  "prettier": "2.8.8"
39
39
  },
@@ -42,5 +42,5 @@
42
42
  "lib"
43
43
  ]
44
44
  },
45
- "gitHead": "ab4413b1c7592b95c0181c8887dc57cc9dac80b7"
45
+ "gitHead": "a3f738ccb11ebe7e6c9984fe06682e6a529285fb"
46
46
  }
package/src/client.js CHANGED
@@ -106,7 +106,7 @@ const initHttpClient = (options) => {
106
106
  ...reqOptions?.headers,
107
107
  ...buildBearerAuthorizationHeader(bearerToken),
108
108
  };
109
- const [origin, path] = buildUrl(host, url, reqOptions, clientOptions);
109
+ const [origin, path] = buildUrl(host, url, reqOptions);
110
110
 
111
111
  log.info({ origin, path, url, reqId, reqHeaders }, 'HttpClient request');
112
112
 
@@ -213,19 +213,22 @@ const parsePrefixUrl = (prefixUrl) => {
213
213
  };
214
214
  };
215
215
 
216
- const buildUrl = (host, url, reqOptions, clientOptions) => {
216
+ const buildUrl = (host, url, reqOptions) => {
217
217
  const fullUrl = reqOptions?.prefixUrl
218
218
  ? new URL(url, reqOptions.prefixUrl).toString()
219
219
  : url;
220
220
 
221
221
  return host && !reqOptions?.prefixUrl
222
222
  ? [host.origin, buildRelativePath(host.rootPath, url, reqOptions)]
223
- : parseFullURL(fullUrl, clientOptions, reqOptions);
223
+ : parseFullURL(fullUrl, reqOptions);
224
224
  };
225
225
 
226
- const parseFullURL = (url, clientOptions, reqOptions) => {
227
- const { origin, pathname } = new URL(url);
228
- return [origin, addSearchParams(pathname, reqOptions?.searchParams)];
226
+ const parseFullURL = (url, reqOptions) => {
227
+ const { origin, pathname, searchParams } = new URL(url);
228
+ return [
229
+ origin,
230
+ addSearchParams(pathname, reqOptions?.searchParams || `${searchParams}`),
231
+ ];
229
232
  };
230
233
 
231
234
  const buildRelativePath = (rootPath, url, reqOptions) =>
@@ -235,7 +238,7 @@ const buildRelativePath = (rootPath, url, reqOptions) =>
235
238
  );
236
239
 
237
240
  const addSearchParams = (path, searchParams) =>
238
- searchParams != null ? `${path}?${searchParams}` : path;
241
+ searchParams?.size || searchParams?.length ? `${path}?${searchParams}` : path;
239
242
 
240
243
  const addCache = (store) =>
241
244
  store ? [interceptors.cache({ store, methods: ['GET'] })] : [];