Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
* removed arrow function
* malformed require path
  • Loading branch information
Sherwin H committed Feb 27, 2019
1 parent 4a7570d commit 6944323
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
34 changes: 21 additions & 13 deletions dist/imgix-core-js.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var constants = require("../src/constants.js");

(function (global, factory) {
if (typeof define === 'function' && define.amd) {
define('Imgix', ['exports', 'md5', 'js-base64', 'crc'], factory);
Expand All @@ -14,15 +16,12 @@
var Base64 = _jsBase64.Base64 || _jsBase64;
var crc = _crc;

var VERSION = '1.2.0';
var SHARD_STRATEGY_CRC = 'crc';
var SHARD_STRATEGY_CYCLE = 'cycle';
var DEFAULTS = {
host: null,
domains: [],
useHTTPS: true,
includeLibraryParam: true,
shard_strategy: SHARD_STRATEGY_CRC
shard_strategy: constants.SHARD_STRATEGY_CRC
};

var ImgixClient = (function() {
Expand Down Expand Up @@ -50,10 +49,10 @@
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) {
if (this.settings.shard_strategy !== constants.SHARD_STRATEGY_CRC
&& this.settings.shard_strategy !== constants.SHARD_STRATEGY_CYCLE) {
throw new Error('Shard strategy must be one of ' +
SHARD_STRATEGY_CRC + ' or ' + SHARD_STRATEGY_CYCLE);
constants.SHARD_STRATEGY_CRC + ' or ' + constants.SHARD_STRATEGY_CYCLE);
}

if (this.settings.host) {
Expand All @@ -62,8 +61,17 @@
this.settings.domains[0] = this.settings.host;
}

this.settings.domains.forEach(function(domain) {
if(constants.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;
this.settings.libraryParam = "js-" + constants.VERSION;
}

this.settings.urlPrefix = this.settings.useHTTPS ? 'https://' : 'http://'
Expand All @@ -85,12 +93,12 @@
};

ImgixClient.prototype._getDomain = function(path) {
if (this.settings.shard_strategy === SHARD_STRATEGY_CYCLE) {
if (this.settings.shard_strategy === constants.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) {
else if (this.settings.shard_strategy === constants.SHARD_STRATEGY_CRC) {
return this.settings.domains[crc.crc32(path) % this.settings.domains.length];
}
}
Expand Down Expand Up @@ -149,9 +157,9 @@
}
};

ImgixClient.VERSION = VERSION;
ImgixClient.SHARD_STRATEGY_CRC = SHARD_STRATEGY_CRC;
ImgixClient.SHARD_STRATEGY_CYCLE = SHARD_STRATEGY_CYCLE;
ImgixClient.VERSION = constants.VERSION;
ImgixClient.SHARD_STRATEGY_CRC = constants.SHARD_STRATEGY_CRC;
ImgixClient.SHARD_STRATEGY_CYCLE = constants.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.

7 changes: 2 additions & 5 deletions src/imgix-core-js.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var constants = require("./constants.js");
var constants = require("../src/constants.js");

(function (global, factory) {
if (typeof define === 'function' && define.amd) {
Expand All @@ -16,9 +16,6 @@ var constants = require("./constants.js");
var Base64 = _jsBase64.Base64 || _jsBase64;
var crc = _crc;

// var VERSION = '1.2.0'
// var SHARD_STRATEGY_CRC = 'crc';
// var SHARD_STRATEGY_CYCLE = 'cycle';
var DEFAULTS = {
host: null,
domains: [],
Expand Down Expand Up @@ -64,7 +61,7 @@ var constants = require("./constants.js");
this.settings.domains[0] = this.settings.host;
}

this.settings.domains.forEach(domain => {
this.settings.domains.forEach(function(domain) {
if(constants.DOMAIN_REGEX.exec(domain) == null){
throw new Error(
'Domains must be passed in as fully-qualified ' +
Expand Down

0 comments on commit 6944323

Please sign in to comment.