Skip to content

Commit

Permalink
chore(release): 3.8.0
Browse files Browse the repository at this point in the history
# [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]
  • Loading branch information
imgix-git-robot committed Jan 13, 2023
1 parent d127a88 commit ba2ec87
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/imgix-js-core.umd.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dist/index.cjs.js
Expand Up @@ -151,7 +151,7 @@ function _toPropertyKey(arg) {
}

// package version used in the ix-lib parameter
var VERSION = '3.7.0';
var VERSION = '3.7.1';
// regex pattern used to determine if a domain is valid
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;
// minimum generated srcset width
Expand Down Expand Up @@ -335,16 +335,17 @@ var ImgixClient = /*#__PURE__*/function () {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// If a custom encoder is present, use it
// Otherwise just use the encodeURIComponent
var encode = options.encoder || encodeURIComponent;
var useCustomEncoder = !!options.encoder;
var customEncoder = options.encoder;
var queryParams = [].concat(_toConsumableArray(this.settings.libraryParam ? ["ixlib=".concat(this.settings.libraryParam)] : []), _toConsumableArray(Object.entries(params).reduce(function (prev, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
if (value == null) {
return prev;
}
var encodedKey = encode(key);
var encodedValue = key.substr(-2) === '64' ? jsBase64.Base64.encodeURI(value) : encode(value);
var encodedKey = useCustomEncoder ? customEncoder(key, value) : encodeURIComponent(key);
var encodedValue = key.substr(-2) === '64' ? useCustomEncoder ? customEncoder(value, key) : jsBase64.Base64.encodeURI(value) : useCustomEncoder ? customEncoder(value, key) : encodeURIComponent(value);
prev.push("".concat(encodedKey, "=").concat(encodedValue));
return prev;
}, [])));
Expand Down
13 changes: 11 additions & 2 deletions dist/index.d.ts
Expand Up @@ -16,8 +16,8 @@ declare class ImgixClient {
params?: {},
options?: { disablePathEncoding?: boolean },
): string;
_sanitizePath(path: string, options?: { encode?: boolean }): string;
_buildParams(params: {}): string;
_sanitizePath(path: string, options?: _sanitizePathOptions): string;
_buildParams(params: {}, options?: _buildParamsOptions): string;
_signParams(path: string, queryParams?: {}): string;
buildSrcSet(path: string, params?: {}, options?: SrcSetOptions): string;
_buildSrcSetPairs(path: string, params?: {}, options?: SrcSetOptions): string;
Expand Down Expand Up @@ -52,4 +52,13 @@ export interface SrcSetOptions {
disablePathEncoding?: boolean;
}

export interface _sanitizePathOptions {
disablePathEncoding?: boolean,
encoder?: (path: string) => string
}

export interface _buildParamsOptions {
encoder?: (value: string, key?: string) => string
}

export default ImgixClient;
9 changes: 5 additions & 4 deletions dist/index.esm.js
Expand Up @@ -145,7 +145,7 @@ function _toPropertyKey(arg) {
}

// package version used in the ix-lib parameter
var VERSION = '3.7.0';
var VERSION = '3.7.1';
// regex pattern used to determine if a domain is valid
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;
// minimum generated srcset width
Expand Down Expand Up @@ -329,16 +329,17 @@ var ImgixClient = /*#__PURE__*/function () {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// If a custom encoder is present, use it
// Otherwise just use the encodeURIComponent
var encode = options.encoder || encodeURIComponent;
var useCustomEncoder = !!options.encoder;
var customEncoder = options.encoder;
var queryParams = [].concat(_toConsumableArray(this.settings.libraryParam ? ["ixlib=".concat(this.settings.libraryParam)] : []), _toConsumableArray(Object.entries(params).reduce(function (prev, _ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
if (value == null) {
return prev;
}
var encodedKey = encode(key);
var encodedValue = key.substr(-2) === '64' ? Base64.encodeURI(value) : encode(value);
var encodedKey = useCustomEncoder ? customEncoder(key, value) : encodeURIComponent(key);
var encodedValue = key.substr(-2) === '64' ? useCustomEncoder ? customEncoder(value, key) : Base64.encodeURI(value) : useCustomEncoder ? customEncoder(value, key) : encodeURIComponent(value);
prev.push("".concat(encodedKey, "=").concat(encodedValue));
return prev;
}, [])));
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "@imgix/js-core",
"description": "A JavaScript client library for generating image URLs with imgix",
"version": "3.7.1",
"version": "3.8.0",
"repository": "https://github.com/imgix/js-core",
"license": "BSD-2-Clause",
"main": "dist/index.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
@@ -1,5 +1,5 @@
// package version used in the ix-lib parameter
export const VERSION = '3.7.1';
export const VERSION = '3.8.0';
// regex pattern used to determine if a domain is valid
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;
// minimum generated srcset width
Expand Down

0 comments on commit ba2ec87

Please sign in to comment.