Skip to content

Commit

Permalink
chore(release): 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sherwin H committed Jun 6, 2019
1 parent 41ef41f commit 23c5b0a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 97 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.5.0"></a>
# [1.5.0](https://github.com/imgix/imgix-core-js/compare/1.4.0...1.5.0) (2019-06-06)

* fix: remove deprecated domain sharding functionality ([#42](https://github.com/imgix/imgix-core-js/pull/42))
* fix: remove deprecated settings.host ([#45](https://github.com/imgix/imgix-core-js/pull/45))


<a name="1.4.0"></a>
## [1.4.0](https://github.com/imgix/imgix-core-js/compare/1.3.0...1.4.0) (2019-06-05)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imgix-core-js",
"version": "1.4.0",
"version": "2.0.0",
"homepage": "https://github.com/imgix/imgix-core-js",
"authors": [
"Kelly Sutton <michael.k.sutton@gmail.com>",
Expand Down
79 changes: 14 additions & 65 deletions dist/imgix-core-js.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
(function (global, factory) {
if (typeof define === 'function' && define.amd) {
define('Imgix', ['exports', 'md5', 'js-base64', 'crc'], factory);
define('Imgix', ['exports', 'md5', 'js-base64'], factory);
} else if (typeof exports !== 'undefined') {
module.exports = factory(exports, require('md5'), require('js-base64').Base64, require('crc'));
module.exports = factory(exports, require('md5'), require('js-base64').Base64);
} else {
var mod = {
exports: {}
};
global.ImgixClient = factory(mod.exports, global.md5, global.Base64, global.crc);
global.ImgixClient = factory(mod.exports, global.md5, global.Base64);
}
})(this, function (exports, _md5, _jsBase64, _crc) {
})(this, function (exports, _md5, _jsBase64) {
var md5 = _md5;
var Base64 = _jsBase64.Base64 || _jsBase64;
var crc = _crc;

var VERSION = '1.4.0';
var SHARD_STRATEGY_CRC = 'crc';
var SHARD_STRATEGY_CYCLE = 'cycle';
var VERSION = '2.0.0';
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;
var DEFAULTS = {
host: null,
domain: null,
domains: [],
useHTTPS: true,
includeLibraryParam: true,
shard_strategy: SHARD_STRATEGY_CRC
includeLibraryParam: true
};

var ImgixClient = (function() {
function ImgixClient(opts) {
var key, val;

this.settings = {};
this._shard_next_index = 0;

for (key in DEFAULTS) {
val = DEFAULTS[key];
Expand All @@ -44,48 +37,17 @@
this.settings[key] = val;
}

if (Array.isArray(this.settings.domains)) {
if (this.settings.domains.length > 1) {
console.warn("Warning: Domain sharding has been deprecated and will be removed in the next major version.\nAs a result, the 'domains' argument will be deprecated in favor of 'domain' instead.");
}
else if (this.settings.domains.length == 0) {
if (typeof(this.settings.domain) != "string" && this.settings.domain != null) {
throw new Error('ImgixClient.settings.domain only accepts a string argument');
}
else {
this.settings.domains = [this.settings.domain];
}
}
}
else {
this.settings.domains = [this.settings.domains];
}

if (!this.settings.host && this.settings.domains == 0) {
throw new Error('ImgixClient must be passed valid domain(s)');
}

if (this.settings.shard_strategy !== SHARD_STRATEGY_CRC
&& this.settings.shard_strategy !== SHARD_STRATEGY_CYCLE) {
throw new Error('Shard strategy must be one of ' +
SHARD_STRATEGY_CRC + ' or ' + SHARD_STRATEGY_CYCLE);
if (typeof this.settings.domain != "string") {
throw new Error('ImgixClient must be passed a valid string domain');
}

if (this.settings.host) {
console.warn("'host' argument is deprecated; either use 'domain' or 'domains' instead.");
if (this.settings.domains.length == 0)
this.settings.domains[0] = this.settings.host;
if (DOMAIN_REGEX.exec(this.settings.domain) == null) {
throw new Error(
'Domain must be passed in as fully-qualified ' +
'domain name and should not include a protocol or any path ' +
'element, i.e. "example.imgix.net".');
}

this.settings.domains.forEach(function(domain) {
if (DOMAIN_REGEX.exec(domain) == null) {
throw new Error(
'Domains must be passed in as fully-qualified ' +
'domain names and should not include a protocol or any path ' +
'element, i.e. "example.imgix.net".');
}
});

if (this.settings.includeLibraryParam) {
this.settings.libraryParam = "js-" + VERSION;
}
Expand All @@ -105,20 +67,9 @@
queryParams = this._signParams(path, queryParams);
}

return this.settings.urlPrefix + this._getDomain(path) + path + queryParams;
return this.settings.urlPrefix + this.settings.domain + path + queryParams;
};

ImgixClient.prototype._getDomain = function(path) {
if (this.settings.shard_strategy === SHARD_STRATEGY_CYCLE) {
var domain = this.settings.domains[this._shard_next_index];
this._shard_next_index = (this._shard_next_index + 1) % this.settings.domains.length;
return domain;
}
else if (this.settings.shard_strategy === SHARD_STRATEGY_CRC) {
return this.settings.domains[crc.crc32(path) % this.settings.domains.length];
}
}

ImgixClient.prototype._sanitizePath = function(path) {
// Strip leading slash first (we'll re-add after encoding)
path = path.replace(/^\//, '');
Expand Down Expand Up @@ -174,8 +125,6 @@
};

ImgixClient.VERSION = VERSION;
ImgixClient.SHARD_STRATEGY_CRC = SHARD_STRATEGY_CRC;
ImgixClient.SHARD_STRATEGY_CYCLE = SHARD_STRATEGY_CYCLE;

return ImgixClient;
})();
Expand Down
2 changes: 1 addition & 1 deletion dist/imgix-core-js.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 1 addition & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "imgix-core-js",
"description": "Common boilerplate for all imgix JavaScript-based functionality.",
"version": "1.4.0",
"version": "2.0.0",
"repository": "https://github.com/imgix/imgix-core-js",
"scripts": {
"assert_version": "node assert_version.js",
Expand Down
2 changes: 1 addition & 1 deletion src/imgix-core-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
var md5 = _md5;
var Base64 = _jsBase64.Base64 || _jsBase64;

var VERSION = '1.4.0';
var VERSION = '2.0.0';
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;
var DEFAULTS = {
domain: null,
Expand Down

0 comments on commit 23c5b0a

Please sign in to comment.