@dotcms/client 0.0.1-beta.4 → 0.0.1-beta.5

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/next.cjs.js CHANGED
@@ -330,12 +330,12 @@ async function _PageClient_getPageFromAPI(path, params) {
330
330
  if (!path) {
331
331
  throw new Error("The 'path' parameter is required for the Page API");
332
332
  }
333
- // Remove leading and trailing slashes from the path.
334
- // Add a leading slash if it's missing.
335
- const pagePath = `/${path.replace(/^\/+/, '').replace(/\/+/g, '/')}${path.endsWith('/') ? '/' : ''}`;
336
- const pageParams = transforms.__classPrivateFieldGet(this, _PageClient_instances, "m", _PageClient_mapToBackendParams).call(this, params || {});
337
- const urlParams = new URLSearchParams(pageParams).toString();
338
- const url = `${this.dotcmsUrl}/api/v1/page/json${pagePath}${urlParams ? `?${urlParams}` : ''}`;
333
+ const normalizedParams = transforms.__classPrivateFieldGet(this, _PageClient_instances, "m", _PageClient_mapToBackendParams).call(this, params || {});
334
+ const queryParams = new URLSearchParams(normalizedParams).toString();
335
+ // If the path starts with a slash, remove it to avoid double slashes in the final URL
336
+ // Because the page path is part of api url path
337
+ const pagePath = path.startsWith('/') ? path.slice(1) : path;
338
+ const url = `${this.dotcmsUrl}/api/v1/page/json/${pagePath}?${queryParams}`;
339
339
  const response = await fetch(url, this.requestOptions);
340
340
  if (!response.ok) {
341
341
  const error = {
package/next.esm.js CHANGED
@@ -328,12 +328,12 @@ async function _PageClient_getPageFromAPI(path, params) {
328
328
  if (!path) {
329
329
  throw new Error("The 'path' parameter is required for the Page API");
330
330
  }
331
- // Remove leading and trailing slashes from the path.
332
- // Add a leading slash if it's missing.
333
- const pagePath = `/${path.replace(/^\/+/, '').replace(/\/+/g, '/')}${path.endsWith('/') ? '/' : ''}`;
334
- const pageParams = __classPrivateFieldGet(this, _PageClient_instances, "m", _PageClient_mapToBackendParams).call(this, params || {});
335
- const urlParams = new URLSearchParams(pageParams).toString();
336
- const url = `${this.dotcmsUrl}/api/v1/page/json${pagePath}${urlParams ? `?${urlParams}` : ''}`;
331
+ const normalizedParams = __classPrivateFieldGet(this, _PageClient_instances, "m", _PageClient_mapToBackendParams).call(this, params || {});
332
+ const queryParams = new URLSearchParams(normalizedParams).toString();
333
+ // If the path starts with a slash, remove it to avoid double slashes in the final URL
334
+ // Because the page path is part of api url path
335
+ const pagePath = path.startsWith('/') ? path.slice(1) : path;
336
+ const url = `${this.dotcmsUrl}/api/v1/page/json/${pagePath}?${queryParams}`;
337
337
  const response = await fetch(url, this.requestOptions);
338
338
  if (!response.ok) {
339
339
  const error = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/client",
3
- "version": "0.0.1-beta.4",
3
+ "version": "0.0.1-beta.5",
4
4
  "description": "Official JavaScript library for interacting with DotCMS REST APIs.",
5
5
  "repository": {
6
6
  "type": "git",