@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.cjs CHANGED
@@ -120,14 +120,15 @@ var createClient = (config) => {
120
120
  }
121
121
  };
122
122
  const buildUrl = (path, query) => {
123
- path = path.replace(/^\/+|\/+$/g, "");
124
- const baseUrl = config.baseUrl.replace(/^\/+|\/+$/g, "");
125
- const url = new URL(`${baseUrl}${path.endsWith("v1") ? "/" : "/v1/"}${path}`);
123
+ const sanitizedPath = path.replace(/^\/+/, "");
124
+ const baseUrl = config.baseUrl.trim().replace(/\/+$/, "");
125
+ const versionedBaseUrl = baseUrl.endsWith("/v1") ? baseUrl : `${baseUrl}/v1`;
126
+ const url = new URL(sanitizedPath, `${versionedBaseUrl.replace(/\/+$/, "")}/`);
126
127
  if (query) {
127
- Object.entries(query).forEach(([key, value]) => {
128
- if (value === void 0 || value === null) return;
128
+ for (const [key, value] of Object.entries(query)) {
129
+ if (value === void 0 || value === null) continue;
129
130
  url.searchParams.append(key, String(value));
130
- });
131
+ }
131
132
  }
132
133
  return url.toString();
133
134
  };