Socket
Socket
Sign inDemoInstall

@commercetools/frontend-sdk

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/frontend-sdk - npm Package Compare versions

Comparing version 1.12.0 to 1.12.1

lib/chunk-L46YLEQC.mjs

7

CHANGELOG.md
## Version 1.12.1 (2024-05-16)
* Fixed edge case with URL normalisation where URL in query replaces domain
## Version 1.12.0 (2024-05-14)
* Added support to add coFE-Custom-Configuration header value globally via configure, and modually on callAction and PageAPI methods

@@ -9,3 +13,2 @@

* Fixed bug in error reporting affecting versions 1.11.0 and 1.11.1

@@ -12,0 +15,0 @@

@@ -577,3 +577,24 @@ "use strict";

// src/helpers/queryStringHelpers.ts
// src/helpers/urlHelpers.ts
var normaliseUrl = function(url) {
let protocolSplit = url.split("//");
let normalisedUrl = "";
if (protocolSplit[0] && (protocolSplit[0] === "http:" || protocolSplit[0] === "https:" || protocolSplit[0] === "ws:" || protocolSplit[0] === "wss:")) {
normalisedUrl = `${protocolSplit[0]}//`;
protocolSplit.splice(0, 1);
}
let query = "";
let querySplit = protocolSplit.join("//").split("?");
if (querySplit.length > 1) {
query = `?${querySplit.slice(1, querySplit.length).join("?")}`;
}
const pathSplit = querySplit[0].split("/");
for (let n = 0; n < pathSplit.length; n++) {
if (pathSplit[n]) {
normalisedUrl += `${pathSplit[n]}/`;
}
}
normalisedUrl = normalisedUrl.substring(0, normalisedUrl.length - 1);
return normalisedUrl + query;
};
var generateQueryString = function(query) {

@@ -718,3 +739,3 @@ const params = new URLSearchParams();

set endpoint(url) {
url = this.#normaliseUrl(url);
url = normaliseUrl(url);
if (url.indexOf("http") === -1) {

@@ -787,8 +808,2 @@ url = `https://${url}`;

}
#normaliseUrl = (url) => url.split("//").reduce((previous, current) => {
if (current === "http:" || current === "https:") {
return current += "/";
}
return `${previous}/${current}`;
}, "");
/**

@@ -804,3 +819,3 @@ * The method that must be called prior to any other methods to configure the connection to the backend. An error is throw if not called prior.

*
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods.
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden on single calls by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods.
* @param {CookieManager} [config.cookieHandlingOverride] - An optional cookie manager interface that contains all the cookie handling methods.

@@ -906,3 +921,3 @@ *

const action = () => fetcher(
this.#normaliseUrl(
normaliseUrl(
`${this.#endpoint}/frontastic/action/${options.actionName}${params}`

@@ -963,5 +978,3 @@ ),

response = await fetcher(
this.#normaliseUrl(
`${this.#endpoint}/frontastic/page${params}`
),
normaliseUrl(`${this.#endpoint}/frontastic/page${params}`),
fetcherOptions,

@@ -1005,3 +1018,3 @@ options.serverOptions,

response = await fetcher(
this.#normaliseUrl(`${this.#endpoint}/frontastic${path}`),
normaliseUrl(`${this.#endpoint}/frontastic${path}`),
fetcherOptions,

@@ -1050,3 +1063,3 @@ options.serverOptions,

response = await fetcher(
this.#normaliseUrl(`${this.#endpoint}/frontastic${path}`),
normaliseUrl(`${this.#endpoint}/frontastic${path}`),
fetcherOptions,

@@ -1053,0 +1066,0 @@ options.serverOptions,

@@ -71,3 +71,3 @@ import { EventManager } from './EventManager.js';

*
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods.
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden on single calls by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods.
* @param {CookieManager} [config.cookieHandlingOverride] - An optional cookie manager interface that contains all the cookie handling methods.

@@ -74,0 +74,0 @@ *

@@ -357,3 +357,24 @@ "use strict";

// src/helpers/queryStringHelpers.ts
// src/helpers/urlHelpers.ts
var normaliseUrl = function(url) {
let protocolSplit = url.split("//");
let normalisedUrl = "";
if (protocolSplit[0] && (protocolSplit[0] === "http:" || protocolSplit[0] === "https:" || protocolSplit[0] === "ws:" || protocolSplit[0] === "wss:")) {
normalisedUrl = `${protocolSplit[0]}//`;
protocolSplit.splice(0, 1);
}
let query = "";
let querySplit = protocolSplit.join("//").split("?");
if (querySplit.length > 1) {
query = `?${querySplit.slice(1, querySplit.length).join("?")}`;
}
const pathSplit = querySplit[0].split("/");
for (let n = 0; n < pathSplit.length; n++) {
if (pathSplit[n]) {
normalisedUrl += `${pathSplit[n]}/`;
}
}
normalisedUrl = normalisedUrl.substring(0, normalisedUrl.length - 1);
return normalisedUrl + query;
};
var generateQueryString = function(query) {

@@ -498,3 +519,3 @@ const params = new URLSearchParams();

set endpoint(url) {
url = this.#normaliseUrl(url);
url = normaliseUrl(url);
if (url.indexOf("http") === -1) {

@@ -567,8 +588,2 @@ url = `https://${url}`;

}
#normaliseUrl = (url) => url.split("//").reduce((previous, current) => {
if (current === "http:" || current === "https:") {
return current += "/";
}
return `${previous}/${current}`;
}, "");
/**

@@ -584,3 +599,3 @@ * The method that must be called prior to any other methods to configure the connection to the backend. An error is throw if not called prior.

*
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods.
* @param {boolean} [options.customHeaderValue] - An optional string, the value to assign to a "coFE-Custom-Configuration" header value in every API call. Overriden on single calls by explicity set customHeaderValue passed in {@link callAction} and {@link PageApi} methods.
* @param {CookieManager} [config.cookieHandlingOverride] - An optional cookie manager interface that contains all the cookie handling methods.

@@ -686,3 +701,3 @@ *

const action = () => fetcher(
this.#normaliseUrl(
normaliseUrl(
`${this.#endpoint}/frontastic/action/${options.actionName}${params}`

@@ -743,5 +758,3 @@ ),

response = await fetcher(
this.#normaliseUrl(
`${this.#endpoint}/frontastic/page${params}`
),
normaliseUrl(`${this.#endpoint}/frontastic/page${params}`),
fetcherOptions,

@@ -785,3 +798,3 @@ options.serverOptions,

response = await fetcher(
this.#normaliseUrl(`${this.#endpoint}/frontastic${path}`),
normaliseUrl(`${this.#endpoint}/frontastic${path}`),
fetcherOptions,

@@ -830,3 +843,3 @@ options.serverOptions,

response = await fetcher(
this.#normaliseUrl(`${this.#endpoint}/frontastic${path}`),
normaliseUrl(`${this.#endpoint}/frontastic${path}`),
fetcherOptions,

@@ -833,0 +846,0 @@ options.serverOptions,

{
"name": "@commercetools/frontend-sdk",
"version": "1.12.0",
"version": "1.12.1",
"license": "UNLICENSED",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc