@borealise/api 2.1.0-alpha.1 → 2.1.0-alpha.3

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.d.mts CHANGED
@@ -1,5 +1,3 @@
1
- import { URLSearchParams } from 'node:url';
2
-
3
1
  interface ApiConfig {
4
2
  baseURL: string;
5
3
  timeout?: number;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { URLSearchParams } from 'node:url';
2
-
3
1
  interface ApiConfig {
4
2
  baseURL: string;
5
3
  timeout?: number;
package/dist/index.js CHANGED
@@ -95,7 +95,6 @@ var parseApiError = async (error) => {
95
95
 
96
96
  // src/api/client.ts
97
97
  var import_ky2 = __toESM(require("ky"));
98
- var import_node_url = require("url");
99
98
 
100
99
  // src/Logger.ts
101
100
  var Logger = class _Logger {
@@ -146,15 +145,23 @@ var Logger = class _Logger {
146
145
  };
147
146
 
148
147
  // src/api/client.ts
149
- var resolveUrl = (baseURL, url) => new import_node_url.URL(url, baseURL).toString();
148
+ var ABSOLUTE_URL_PATTERN = /^[a-z][a-z\d+\-.]*:\/\//i;
149
+ var resolveUrl = (baseURL, url) => {
150
+ if (ABSOLUTE_URL_PATTERN.test(url)) {
151
+ return url;
152
+ }
153
+ const normalizedBase = baseURL.replace(/\/+$/, "");
154
+ const normalizedPath = url.replace(/^\/+/, "");
155
+ return `${normalizedBase}/${normalizedPath}`;
156
+ };
150
157
  var parseQueryParams = (params) => {
151
158
  if (!params) {
152
159
  return void 0;
153
160
  }
154
- if (params instanceof import_node_url.URLSearchParams) {
161
+ if (params instanceof URLSearchParams) {
155
162
  return params;
156
163
  }
157
- const searchParams = new import_node_url.URLSearchParams();
164
+ const searchParams = new URLSearchParams();
158
165
  for (const [key, value] of Object.entries(params)) {
159
166
  if (value === void 0 || value === null) {
160
167
  continue;
package/dist/index.mjs CHANGED
@@ -46,7 +46,6 @@ var parseApiError = async (error) => {
46
46
 
47
47
  // src/api/client.ts
48
48
  import ky from "ky";
49
- import { URL, URLSearchParams as URLSearchParams2 } from "url";
50
49
 
51
50
  // src/Logger.ts
52
51
  var Logger = class _Logger {
@@ -97,15 +96,23 @@ var Logger = class _Logger {
97
96
  };
98
97
 
99
98
  // src/api/client.ts
100
- var resolveUrl = (baseURL, url) => new URL(url, baseURL).toString();
99
+ var ABSOLUTE_URL_PATTERN = /^[a-z][a-z\d+\-.]*:\/\//i;
100
+ var resolveUrl = (baseURL, url) => {
101
+ if (ABSOLUTE_URL_PATTERN.test(url)) {
102
+ return url;
103
+ }
104
+ const normalizedBase = baseURL.replace(/\/+$/, "");
105
+ const normalizedPath = url.replace(/^\/+/, "");
106
+ return `${normalizedBase}/${normalizedPath}`;
107
+ };
101
108
  var parseQueryParams = (params) => {
102
109
  if (!params) {
103
110
  return void 0;
104
111
  }
105
- if (params instanceof URLSearchParams2) {
112
+ if (params instanceof URLSearchParams) {
106
113
  return params;
107
114
  }
108
- const searchParams = new URLSearchParams2();
115
+ const searchParams = new URLSearchParams();
109
116
  for (const [key, value] of Object.entries(params)) {
110
117
  if (value === void 0 || value === null) {
111
118
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@borealise/api",
3
- "version": "2.1.0-alpha.1",
3
+ "version": "2.1.0-alpha.3",
4
4
  "description": "Official API client for Borealise",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",