Skip to content

Commit ba2ec87

Browse files
author
imgix-git-robot
committed
chore(release): 3.8.0
# [3.8.0](v3.7.1...v3.8.0) (2023-01-13) ### Bug Fixes * apply custom encoder to base64 parameters ([3ca78e1](3ca78e1)) ### Features * add optional key parameter to custom encoder when encoding k,v pairs ([1023ab1](1023ab1)) [skip ci]
1 parent d127a88 commit ba2ec87

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

dist/imgix-js-core.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.cjs.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function _toPropertyKey(arg) {
151151
}
152152

153153
// package version used in the ix-lib parameter
154-
var VERSION = '3.7.0';
154+
var VERSION = '3.7.1';
155155
// regex pattern used to determine if a domain is valid
156156
var DOMAIN_REGEX = /^(?:[a-z\d\-_]{1,62}\.){0,125}(?:[a-z\d](?:\-(?=\-*[a-z\d])|[a-z]|\d){0,62}\.)[a-z\d]{1,63}$/i;
157157
// minimum generated srcset width
@@ -335,16 +335,17 @@ var ImgixClient = /*#__PURE__*/function () {
335335
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
336336
// If a custom encoder is present, use it
337337
// Otherwise just use the encodeURIComponent
338-
var encode = options.encoder || encodeURIComponent;
338+
var useCustomEncoder = !!options.encoder;
339+
var customEncoder = options.encoder;
339340
var queryParams = [].concat(_toConsumableArray(this.settings.libraryParam ? ["ixlib=".concat(this.settings.libraryParam)] : []), _toConsumableArray(Object.entries(params).reduce(function (prev, _ref) {
340341
var _ref2 = _slicedToArray(_ref, 2),
341342
key = _ref2[0],
342343
value = _ref2[1];
343344
if (value == null) {
344345
return prev;
345346
}
346-
var encodedKey = encode(key);
347-
var encodedValue = key.substr(-2) === '64' ? jsBase64.Base64.encodeURI(value) : encode(value);
347+
var encodedKey = useCustomEncoder ? customEncoder(key, value) : encodeURIComponent(key);
348+
var encodedValue = key.substr(-2) === '64' ? useCustomEncoder ? customEncoder(value, key) : jsBase64.Base64.encodeURI(value) : useCustomEncoder ? customEncoder(value, key) : encodeURIComponent(value);
348349
prev.push("".concat(encodedKey, "=").concat(encodedValue));
349350
return prev;
350351
}, [])));

dist/index.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ declare class ImgixClient {
1616
params?: {},
1717
options?: { disablePathEncoding?: boolean },
1818
): string;
19-
_sanitizePath(path: string, options?: { encode?: boolean }): string;
20-
_buildParams(params: {}): string;
19+
_sanitizePath(path: string, options?: _sanitizePathOptions): string;
20+
_buildParams(params: {}, options?: _buildParamsOptions): string;
2121
_signParams(path: string, queryParams?: {}): string;
2222
buildSrcSet(path: string, params?: {}, options?: SrcSetOptions): string;
2323
_buildSrcSetPairs(path: string, params?: {}, options?: SrcSetOptions): string;
@@ -52,4 +52,13 @@ export interface SrcSetOptions {
5252
disablePathEncoding?: boolean;
5353
}
5454

55+
export interface _sanitizePathOptions {
56+
disablePathEncoding?: boolean,
57+
encoder?: (path: string) => string
58+
}
59+
60+
export interface _buildParamsOptions {
61+
encoder?: (value: string, key?: string) => string
62+
}
63+
5564
export default ImgixClient;

dist/index.esm.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function _toPropertyKey(arg) {
145145
}
146146

147147
// package version used in the ix-lib parameter
148-
var VERSION = '3.7.0';
148+
var VERSION = '3.7.1';
149149
// regex pattern used to determine if a domain is valid
150150
var DOMAIN_REGEX = /^(?:[a-z\d\-_]{1,62}\.){0,125}(?:[a-z\d](?:\-(?=\-*[a-z\d])|[a-z]|\d){0,62}\.)[a-z\d]{1,63}$/i;
151151
// minimum generated srcset width
@@ -329,16 +329,17 @@ var ImgixClient = /*#__PURE__*/function () {
329329
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
330330
// If a custom encoder is present, use it
331331
// Otherwise just use the encodeURIComponent
332-
var encode = options.encoder || encodeURIComponent;
332+
var useCustomEncoder = !!options.encoder;
333+
var customEncoder = options.encoder;
333334
var queryParams = [].concat(_toConsumableArray(this.settings.libraryParam ? ["ixlib=".concat(this.settings.libraryParam)] : []), _toConsumableArray(Object.entries(params).reduce(function (prev, _ref) {
334335
var _ref2 = _slicedToArray(_ref, 2),
335336
key = _ref2[0],
336337
value = _ref2[1];
337338
if (value == null) {
338339
return prev;
339340
}
340-
var encodedKey = encode(key);
341-
var encodedValue = key.substr(-2) === '64' ? Base64.encodeURI(value) : encode(value);
341+
var encodedKey = useCustomEncoder ? customEncoder(key, value) : encodeURIComponent(key);
342+
var encodedValue = key.substr(-2) === '64' ? useCustomEncoder ? customEncoder(value, key) : Base64.encodeURI(value) : useCustomEncoder ? customEncoder(value, key) : encodeURIComponent(value);
342343
prev.push("".concat(encodedKey, "=").concat(encodedValue));
343344
return prev;
344345
}, [])));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@imgix/js-core",
33
"description": "A JavaScript client library for generating image URLs with imgix",
4-
"version": "3.7.1",
4+
"version": "3.8.0",
55
"repository": "https://github.com/imgix/js-core",
66
"license": "BSD-2-Clause",
77
"main": "dist/index.cjs.js",

src/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// package version used in the ix-lib parameter
2-
export const VERSION = '3.7.1';
2+
export const VERSION = '3.8.0';
33
// regex pattern used to determine if a domain is valid
44
export const DOMAIN_REGEX = /^(?:[a-z\d\-_]{1,62}\.){0,125}(?:[a-z\d](?:\-(?=\-*[a-z\d])|[a-z]|\d){0,62}\.)[a-z\d]{1,63}$/i;
55
// minimum generated srcset width

0 commit comments

Comments
 (0)