brainerce 1.27.0 → 1.27.1

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
@@ -193,6 +193,15 @@ function getDirectionForLocale(locale) {
193
193
  const primary = locale.split("-")[0].toLowerCase();
194
194
  return RTL_LOCALES.has(primary) ? "rtl" : "ltr";
195
195
  }
196
+ function encodePathSegment(value) {
197
+ let normalized = value;
198
+ try {
199
+ normalized = decodeURIComponent(value);
200
+ } catch {
201
+ normalized = value;
202
+ }
203
+ return encodeURIComponent(normalized);
204
+ }
196
205
  var BrainerceClient = class {
197
206
  constructor(options) {
198
207
  this.customerToken = null;
@@ -408,7 +417,7 @@ var BrainerceClient = class {
408
417
  */
409
418
  getBySlug: async (slug, locale) => {
410
419
  const query = locale ? { locale } : void 0;
411
- const path = `/content/pages/by-slug/${encodeURIComponent(slug)}`;
420
+ const path = `/content/pages/by-slug/${encodePathSegment(slug)}`;
412
421
  const onNotFound = (err) => {
413
422
  if (err instanceof BrainerceError && err.statusCode === 404) return null;
414
423
  throw err;
@@ -994,7 +1003,7 @@ var BrainerceClient = class {
994
1003
  */
995
1004
  async getProductBySlug(slug, options) {
996
1005
  const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
997
- const encodedSlug = encodeURIComponent(slug);
1006
+ const encodedSlug = encodePathSegment(slug);
998
1007
  if (this.isVibeCodedMode()) {
999
1008
  return this.vibeCodedRequest(
1000
1009
  "GET",
package/dist/index.mjs CHANGED
@@ -126,6 +126,15 @@ function getDirectionForLocale(locale) {
126
126
  const primary = locale.split("-")[0].toLowerCase();
127
127
  return RTL_LOCALES.has(primary) ? "rtl" : "ltr";
128
128
  }
129
+ function encodePathSegment(value) {
130
+ let normalized = value;
131
+ try {
132
+ normalized = decodeURIComponent(value);
133
+ } catch {
134
+ normalized = value;
135
+ }
136
+ return encodeURIComponent(normalized);
137
+ }
129
138
  var BrainerceClient = class {
130
139
  constructor(options) {
131
140
  this.customerToken = null;
@@ -341,7 +350,7 @@ var BrainerceClient = class {
341
350
  */
342
351
  getBySlug: async (slug, locale) => {
343
352
  const query = locale ? { locale } : void 0;
344
- const path = `/content/pages/by-slug/${encodeURIComponent(slug)}`;
353
+ const path = `/content/pages/by-slug/${encodePathSegment(slug)}`;
345
354
  const onNotFound = (err) => {
346
355
  if (err instanceof BrainerceError && err.statusCode === 404) return null;
347
356
  throw err;
@@ -927,7 +936,7 @@ var BrainerceClient = class {
927
936
  */
928
937
  async getProductBySlug(slug, options) {
929
938
  const headerOverrides = options?.locale ? { "Accept-Language": options.locale } : void 0;
930
- const encodedSlug = encodeURIComponent(slug);
939
+ const encodedSlug = encodePathSegment(slug);
931
940
  if (this.isVibeCodedMode()) {
932
941
  return this.vibeCodedRequest(
933
942
  "GET",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainerce",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "Official SDK for building e-commerce storefronts with Brainerce Platform. Perfect for vibe-coded sites, AI-built stores (Cursor, Lovable, v0), and custom storefronts.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",