@bytescale/sdk 1.0.0-alpha.6 → 1.0.0-alpha.7

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.
@@ -448,7 +448,15 @@ var BaseAPI = /*#__PURE__*/function () {
448
448
  }, {
449
449
  key: "encodeParam",
450
450
  value: function encodeParam(paramName, paramValue) {
451
- return paramName === "filePath" ? paramValue : encodeURIComponent(paramValue);
451
+ if (paramName === "filePath") {
452
+ if (!paramValue.startsWith("/")) {
453
+ // Non-obvious errors are returned by the Bytescale CDN if forward slashes are omitted, so catch it client-side:
454
+ throw new Error("The 'filePath' parameter must begin with a '/' character.");
455
+ }
456
+ // We must not encode the filePath param (as slashes are valid).
457
+ return paramValue;
458
+ }
459
+ return encodeURIComponent(paramValue);
452
460
  }
453
461
  }, {
454
462
  key: "createFetchParams",
@@ -294,7 +294,15 @@ var BaseAPI = /*#__PURE__*/function () {
294
294
  }, {
295
295
  key: "encodeParam",
296
296
  value: function encodeParam(paramName, paramValue) {
297
- return paramName === "filePath" ? paramValue : encodeURIComponent(paramValue);
297
+ if (paramName === "filePath") {
298
+ if (!paramValue.startsWith("/")) {
299
+ // Non-obvious errors are returned by the Bytescale CDN if forward slashes are omitted, so catch it client-side:
300
+ throw new Error("The 'filePath' parameter must begin with a '/' character.");
301
+ }
302
+ // We must not encode the filePath param (as slashes are valid).
303
+ return paramValue;
304
+ }
305
+ return encodeURIComponent(paramValue);
298
306
  }
299
307
  }, {
300
308
  key: "createFetchParams",
@@ -255,7 +255,15 @@ var BaseAPI = /*#__PURE__*/function () {
255
255
  }, {
256
256
  key: "encodeParam",
257
257
  value: function encodeParam(paramName, paramValue) {
258
- return paramName === "filePath" ? paramValue : encodeURIComponent(paramValue);
258
+ if (paramName === "filePath") {
259
+ if (!paramValue.startsWith("/")) {
260
+ // Non-obvious errors are returned by the Bytescale CDN if forward slashes are omitted, so catch it client-side:
261
+ throw new Error("The 'filePath' parameter must begin with a '/' character.");
262
+ }
263
+ // We must not encode the filePath param (as slashes are valid).
264
+ return paramValue;
265
+ }
266
+ return encodeURIComponent(paramValue);
259
267
  }
260
268
  }, {
261
269
  key: "createFetchParams",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",