exnet-routing 1.1.5 → 1.1.7

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.
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable no-console */
7
6
  const index_1 = require("../../index");
8
7
  const axios_1 = __importDefault(require("axios"));
9
8
  const setup_1 = require("../setup");
@@ -179,6 +179,7 @@ describe("Ops Routes", () => {
179
179
  direction: "desc",
180
180
  },
181
181
  });
182
+ expect(response.data.data[0].id).toBe(1);
182
183
  });
183
184
  });
184
185
  });
@@ -219,6 +220,7 @@ describe("Ops Routes", () => {
219
220
  direction: "desc",
220
221
  },
221
222
  });
223
+ expect(response.data.data[0].id).toBe(1);
222
224
  });
223
225
  });
224
226
  });
@@ -27,27 +27,29 @@ exports.apiFetch = {
27
27
  fetch: async (urlInput, method, body, searchParams, queryParams) => {
28
28
  try {
29
29
  let url = (0, exports.apiUrlBuilder)(urlInput, baseUrl, host);
30
- if (queryParams) {
31
- const queryString = Object.entries(queryParams)
32
- .filter(([_, value]) => value !== undefined && value !== null)
33
- .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
34
- .join("&");
35
- url += (url.includes("?") ? "&" : "?") + queryString;
30
+ // Remplacer les paramètres dynamiques dans l'URL
31
+ if (queryParams && typeof queryParams === 'object') {
32
+ Object.entries(queryParams).forEach(([key, value]) => {
33
+ if (value !== undefined && value !== null) {
34
+ const placeholder = `:${key}`;
35
+ if (url.includes(placeholder)) {
36
+ url = url.replace(placeholder, String(value));
37
+ }
38
+ }
39
+ });
36
40
  }
37
- if (searchParams) {
38
- const searchParamsString = typeof searchParams === "string"
39
- ? searchParams
40
- : Object.entries(searchParams)
41
- .filter(([_, value]) => value !== undefined && value !== null)
42
- .map(([key, value]) => {
43
- const encodedKey = encodeURIComponent(key);
44
- const encodedValue = Array.isArray(value) || typeof value === "object"
45
- ? encodeURIComponent(JSON.stringify(value))
46
- : encodeURIComponent(String(value !== null && value !== void 0 ? value : ""));
47
- return `${encodedKey}=${encodedValue}`;
48
- })
49
- .join("&");
50
- url += (url.includes("?") ? "&" : "?") + searchParamsString;
41
+ // Ajouter les paramètres de recherche
42
+ const finalSearchParams = new URLSearchParams();
43
+ if (searchParams && typeof searchParams === 'object') {
44
+ Object.entries(searchParams).forEach(([key, value]) => {
45
+ if (value !== undefined && value !== null) {
46
+ finalSearchParams.append(key, String(value));
47
+ }
48
+ });
49
+ const searchString = finalSearchParams.toString();
50
+ if (searchString) {
51
+ url += (url.includes('?') ? '&' : '?') + searchString;
52
+ }
51
53
  }
52
54
  const res = await (0, axios_1.default)({
53
55
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exnet-routing",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [