@doujins/payments-ui 0.1.5 → 0.1.6

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/index.js CHANGED
@@ -88,14 +88,15 @@ var createClient = (config) => {
88
88
  }
89
89
  };
90
90
  const buildUrl = (path, query) => {
91
- path = path.replace(/^\/+|\/+$/g, "");
92
- const baseUrl = config.baseUrl.replace(/^\/+|\/+$/g, "");
93
- const url = new URL(`${baseUrl}${path.endsWith("v1") ? "/" : "/v1/"}${path}`);
91
+ const sanitizedPath = path.replace(/^\/+/, "");
92
+ const baseUrl = config.baseUrl.trim().replace(/\/+$/, "");
93
+ const versionedBaseUrl = baseUrl.endsWith("/v1") ? baseUrl : `${baseUrl}/v1`;
94
+ const url = new URL(sanitizedPath, `${versionedBaseUrl.replace(/\/+$/, "")}/`);
94
95
  if (query) {
95
- Object.entries(query).forEach(([key, value]) => {
96
- if (value === void 0 || value === null) return;
96
+ for (const [key, value] of Object.entries(query)) {
97
+ if (value === void 0 || value === null) continue;
97
98
  url.searchParams.append(key, String(value));
98
- });
99
+ }
99
100
  }
100
101
  return url.toString();
101
102
  };