merchi_sdk_ts 1.0.72-test-a → 1.0.72-test-c

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.
package/dist/merchi.js CHANGED
@@ -194,16 +194,10 @@ var Merchi = /** @class */ (function () {
194
194
  if (!determinedBaseUri) {
195
195
  determinedBaseUri = 'https://api.merchi.co/';
196
196
  }
197
- // Ensure determinedBaseUri ends with a slash before appending version
197
+ // Ensure determinedBaseUri ends with a slash
198
198
  if (!determinedBaseUri.endsWith('/')) {
199
199
  determinedBaseUri += '/';
200
200
  }
201
- // Check if the URI already includes the API version
202
- var versionPattern = new RegExp("/".concat(API_VERSION, "/?$"));
203
- if (!versionPattern.test(determinedBaseUri)) {
204
- determinedBaseUri += API_VERSION + '/';
205
- }
206
- console.log('what is determinedBaseUri', determinedBaseUri);
207
201
  this.backendUri = determinedBaseUri;
208
202
  // re-export configured versions of all classes
209
203
  this.AutomaticPaymentRelationship = this.setupClass(AutomaticPaymentRelationship);
package/dist/request.js CHANGED
@@ -45,9 +45,25 @@ var ApiError = /** @class */ (function (_super) {
45
45
  }(Error));
46
46
  export { ApiError };
47
47
  export var version = 'v6';
48
+ function ensureVersionInUri(baseUrl) {
49
+ // Ensure baseUrl ends with a slash
50
+ var uri = baseUrl;
51
+ if (!uri.endsWith('/')) {
52
+ uri += '/';
53
+ }
54
+ // Check if the URI already includes the API version
55
+ var versionPattern = new RegExp("/".concat(version, "/?$"));
56
+ if (!versionPattern.test(uri)) {
57
+ uri += version + '/';
58
+ }
59
+ return uri;
60
+ }
48
61
  export function backendFetch(baseUrl, resource, options) {
49
62
  var e_1, _a;
50
- var url = new URL(resource, baseUrl);
63
+ var uriWithVersion = ensureVersionInUri(baseUrl);
64
+ // Remove leading slash from resource if it exists to prevent double slashes
65
+ var cleanResource = resource.startsWith('/') ? resource.slice(1) : resource;
66
+ var url = new URL(uriWithVersion + cleanResource);
51
67
  if (options && options.query) {
52
68
  try {
53
69
  for (var _b = __values(options.query), _c = _b.next(); !_c.done; _c = _b.next()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_sdk_ts",
3
- "version": "1.0.72-test-a",
3
+ "version": "1.0.72-test-c",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:merchisdk/merchi_sdk_ts.git",
package/src/merchi.ts CHANGED
@@ -240,18 +240,11 @@ export class Merchi {
240
240
  determinedBaseUri = 'https://api.merchi.co/';
241
241
  }
242
242
 
243
- // Ensure determinedBaseUri ends with a slash before appending version
243
+ // Ensure determinedBaseUri ends with a slash
244
244
  if (!determinedBaseUri.endsWith('/')) {
245
245
  determinedBaseUri += '/';
246
246
  }
247
247
 
248
- // Check if the URI already includes the API version
249
- const versionPattern = new RegExp(`/${API_VERSION}/?$`);
250
- if (!versionPattern.test(determinedBaseUri)) {
251
- determinedBaseUri += API_VERSION + '/';
252
- }
253
-
254
- console.log('what is determinedBaseUri', determinedBaseUri);
255
248
  this.backendUri = determinedBaseUri;
256
249
 
257
250
  // re-export configured versions of all classes
package/src/request.ts CHANGED
@@ -25,8 +25,27 @@ export class ApiError extends Error {
25
25
 
26
26
  export const version = 'v6';
27
27
 
28
+ function ensureVersionInUri(baseUrl: string): string {
29
+ // Ensure baseUrl ends with a slash
30
+ let uri = baseUrl;
31
+ if (!uri.endsWith('/')) {
32
+ uri += '/';
33
+ }
34
+
35
+ // Check if the URI already includes the API version
36
+ const versionPattern = new RegExp(`/${version}/?$`);
37
+ if (!versionPattern.test(uri)) {
38
+ uri += version + '/';
39
+ }
40
+
41
+ return uri;
42
+ }
43
+
28
44
  export function backendFetch(baseUrl: string, resource: string, options?: RequestOptions) {
29
- const url = new URL(resource, baseUrl);
45
+ const uriWithVersion = ensureVersionInUri(baseUrl);
46
+ // Remove leading slash from resource if it exists to prevent double slashes
47
+ const cleanResource = resource.startsWith('/') ? resource.slice(1) : resource;
48
+ const url = new URL(uriWithVersion + cleanResource);
30
49
  if (options && options.query) {
31
50
  for (const entry of options.query) {
32
51
  url.searchParams.append(entry[0], entry[1]);