Skip to content

Commit

Permalink
chore(release): 3.7.0
Browse files Browse the repository at this point in the history
# [3.7.0](v3.6.1...v3.7.0) (2022-10-31)

### Features

* enable custom paramter and url encoding function ([1f5649a](1f5649a))

 [skip ci]
  • Loading branch information
imgix-git-robot committed Oct 31, 2022
1 parent a14ad48 commit 4208000
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion dist/imgix-js-core.umd.js

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions dist/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function _nonIterableRest() {
}

// package version used in the ix-lib parameter
var VERSION = '3.6.0'; // regex pattern used to determine if a domain is valid
var VERSION = '3.6.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 @@ -321,11 +321,9 @@ var ImgixClient = /*#__PURE__*/function () {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

var path = this._sanitizePath(rawPath, {
encode: !options.disablePathEncoding
});
var path = this._sanitizePath(rawPath, options);

var finalParams = this._buildParams(params);
var finalParams = this._buildParams(params, options);

if (!!this.settings.secureURLToken) {
finalParams = this._signParams(path, finalParams);
Expand Down Expand Up @@ -361,6 +359,10 @@ var ImgixClient = /*#__PURE__*/function () {
key: "_buildParams",
value: function _buildParams() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
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 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],
Expand All @@ -370,8 +372,8 @@ var ImgixClient = /*#__PURE__*/function () {
return prev;
}

var encodedKey = encodeURIComponent(key);
var encodedValue = key.substr(-2) === '64' ? jsBase64.Base64.encodeURI(value) : encodeURIComponent(value);
var encodedKey = encode(key);
var encodedValue = key.substr(-2) === '64' ? jsBase64.Base64.encodeURI(value) : encode(value);
prev.push("".concat(encodedKey, "=").concat(encodedValue));
return prev;
}, [])));
Expand Down Expand Up @@ -403,16 +405,20 @@ var ImgixClient = /*#__PURE__*/function () {
// Strip leading slash first (we'll re-add after encoding)
var _path = path.replace(/^\//, '');

if (!(options.encode === false)) {
if (/^https?:\/\//.test(_path)) {
// Use de/encodeURIComponent to ensure *all* characters are handled,
// since it's being used as a path
_path = encodeURIComponent(_path);
} else {
// Use de/encodeURI if we think the path is just a path,
// so it leaves legal characters like '/' and '@' alone
_path = encodeURI(_path).replace(/[#?:+]/g, encodeURIComponent);
}
if (options.disablePathEncoding) {
return '/' + _path;
}

if (options.encoder) {
_path = options.encoder(_path);
} else if (/^https?:\/\//.test(_path)) {
// Use de/encodeURIComponent to ensure *all* characters are handled,
// since it's being used as a path
_path = encodeURIComponent(_path);
} else {
// Use de/encodeURI if we think the path is just a path,
// so it leaves legal characters like '/' and '@' alone
_path = encodeURI(_path).replace(/[#?:+]/g, encodeURIComponent);
}

return '/' + _path;
Expand Down Expand Up @@ -472,9 +478,7 @@ var ImgixClient = /*#__PURE__*/function () {
var srcset = targetWidthValues.map(function (w) {
return "".concat(_this.buildURL(path, _objectSpread2(_objectSpread2({}, params), {}, {
w: w
}), {
disablePathEncoding: options.disablePathEncoding
}), " ").concat(w, "w");
}), options), " ").concat(w, "w");
});
return srcset.join(',\n');
}
Expand Down Expand Up @@ -507,17 +511,13 @@ var ImgixClient = /*#__PURE__*/function () {
return "".concat(_this2.buildURL(path, _objectSpread2(_objectSpread2({}, params), {}, {
dpr: dpr,
q: params.q || qualities[dpr] || qualities[Math.floor(dpr)]
}), {
disablePathEncoding: options.disablePathEncoding
}), " ").concat(dpr, "x");
}), options), " ").concat(dpr, "x");
};

var srcset = disableVariableQuality ? targetRatios.map(function (dpr) {
return "".concat(_this2.buildURL(path, _objectSpread2(_objectSpread2({}, params), {}, {
dpr: dpr
}), {
disablePathEncoding: options.disablePathEncoding
}), " ").concat(dpr, "x");
}), options), " ").concat(dpr, "x");
}) : targetRatios.map(function (dpr) {
return withQuality(path, params, dpr);
});
Expand Down
52 changes: 26 additions & 26 deletions dist/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function _nonIterableRest() {
}

// package version used in the ix-lib parameter
var VERSION = '3.6.0'; // regex pattern used to determine if a domain is valid
var VERSION = '3.6.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 @@ -315,11 +315,9 @@ var ImgixClient = /*#__PURE__*/function () {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

var path = this._sanitizePath(rawPath, {
encode: !options.disablePathEncoding
});
var path = this._sanitizePath(rawPath, options);

var finalParams = this._buildParams(params);
var finalParams = this._buildParams(params, options);

if (!!this.settings.secureURLToken) {
finalParams = this._signParams(path, finalParams);
Expand Down Expand Up @@ -355,6 +353,10 @@ var ImgixClient = /*#__PURE__*/function () {
key: "_buildParams",
value: function _buildParams() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
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 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],
Expand All @@ -364,8 +366,8 @@ var ImgixClient = /*#__PURE__*/function () {
return prev;
}

var encodedKey = encodeURIComponent(key);
var encodedValue = key.substr(-2) === '64' ? Base64.encodeURI(value) : encodeURIComponent(value);
var encodedKey = encode(key);
var encodedValue = key.substr(-2) === '64' ? Base64.encodeURI(value) : encode(value);
prev.push("".concat(encodedKey, "=").concat(encodedValue));
return prev;
}, [])));
Expand Down Expand Up @@ -397,16 +399,20 @@ var ImgixClient = /*#__PURE__*/function () {
// Strip leading slash first (we'll re-add after encoding)
var _path = path.replace(/^\//, '');

if (!(options.encode === false)) {
if (/^https?:\/\//.test(_path)) {
// Use de/encodeURIComponent to ensure *all* characters are handled,
// since it's being used as a path
_path = encodeURIComponent(_path);
} else {
// Use de/encodeURI if we think the path is just a path,
// so it leaves legal characters like '/' and '@' alone
_path = encodeURI(_path).replace(/[#?:+]/g, encodeURIComponent);
}
if (options.disablePathEncoding) {
return '/' + _path;
}

if (options.encoder) {
_path = options.encoder(_path);
} else if (/^https?:\/\//.test(_path)) {
// Use de/encodeURIComponent to ensure *all* characters are handled,
// since it's being used as a path
_path = encodeURIComponent(_path);
} else {
// Use de/encodeURI if we think the path is just a path,
// so it leaves legal characters like '/' and '@' alone
_path = encodeURI(_path).replace(/[#?:+]/g, encodeURIComponent);
}

return '/' + _path;
Expand Down Expand Up @@ -466,9 +472,7 @@ var ImgixClient = /*#__PURE__*/function () {
var srcset = targetWidthValues.map(function (w) {
return "".concat(_this.buildURL(path, _objectSpread2(_objectSpread2({}, params), {}, {
w: w
}), {
disablePathEncoding: options.disablePathEncoding
}), " ").concat(w, "w");
}), options), " ").concat(w, "w");
});
return srcset.join(',\n');
}
Expand Down Expand Up @@ -501,17 +505,13 @@ var ImgixClient = /*#__PURE__*/function () {
return "".concat(_this2.buildURL(path, _objectSpread2(_objectSpread2({}, params), {}, {
dpr: dpr,
q: params.q || qualities[dpr] || qualities[Math.floor(dpr)]
}), {
disablePathEncoding: options.disablePathEncoding
}), " ").concat(dpr, "x");
}), options), " ").concat(dpr, "x");
};

var srcset = disableVariableQuality ? targetRatios.map(function (dpr) {
return "".concat(_this2.buildURL(path, _objectSpread2(_objectSpread2({}, params), {}, {
dpr: dpr
}), {
disablePathEncoding: options.disablePathEncoding
}), " ").concat(dpr, "x");
}), options), " ").concat(dpr, "x");
}) : targetRatios.map(function (dpr) {
return withQuality(path, params, dpr);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@imgix/js-core",
"description": "A JavaScript client library for generating image URLs with imgix",
"version": "3.6.1",
"version": "3.7.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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// package version used in the ix-lib parameter
export const VERSION = '3.6.1';
export const VERSION = '3.7.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 4208000

Please sign in to comment.