@imgix/js-core
Advanced tools
@@ -1,1 +0,1 @@ | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ImgixClient=e()}(this,function(){"use strict";function e(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function s(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach(function(t){var e,r;e=n,t=o[r=t],r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,u=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(u)throw o}}return i}}(t,e)||r(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(r="Object"===r&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function t(t,e){return t(e={exports:{}},e.exports),e.exports}function i(t){return null!=t&&(d(t)||"function"==typeof(e=t).readFloatLE&&"function"==typeof e.slice&&d(e.slice(0,0))||!!t._isBuffer);var e}var a=t(function(t){var i,r;i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(t,e){return t<<e|t>>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&r.rotl(t,8)|4278255360&r.rotl(t,24);for(var e=0;e<t.length;e++)t[e]=r.endian(t[e]);return t},randomBytes:function(t){for(var e=[];0<t;t--)e.push(Math.floor(256*Math.random()));return e},bytesToWords:function(t){for(var e=[],r=0,n=0;r<t.length;r++,n+=8)e[n>>>5]|=t[r]<<24-n%32;return e},wordsToBytes:function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},bytesToHex:function(t){for(var e=[],r=0;r<t.length;r++)e.push((t[r]>>>4).toString(16)),e.push((15&t[r]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],r=0;r<t.length;r+=2)e.push(parseInt(t.substr(r,2),16));return e},bytesToBase64:function(t){for(var e=[],r=0;r<t.length;r+=3)for(var n=t[r]<<16|t[r+1]<<8|t[r+2],o=0;o<4;o++)8*r+6*o<=8*t.length?e.push(i.charAt(n>>>6*(3-o)&63)):e.push("=");return e.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],r=0,n=0;r<t.length;n=++r%4)0!=n&&e.push((i.indexOf(t.charAt(r-1))&Math.pow(2,-2*n+8)-1)<<2*n|i.indexOf(t.charAt(r))>>>6-2*n);return e}},t.exports=r}),u={utf8:{stringToBytes:function(t){return u.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(u.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e},bytesToString:function(t){for(var e=[],r=0;r<t.length;r++)e.push(String.fromCharCode(t[r]));return e.join("")}}},h=u;function d(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var y=t(function(t){function p(t,e){t.constructor==String?t=(e&&"binary"===e.encoding?w:m).stringToBytes(t):v(t)?t=Array.prototype.slice.call(t,0):Array.isArray(t)||(t=t.toString());for(var r=g.bytesToWords(t),t=8*t.length,n=1732584193,o=-271733879,i=-1732584194,a=271733878,u=0;u<r.length;u++)r[u]=16711935&(r[u]<<8|r[u]>>>24)|4278255360&(r[u]<<24|r[u]>>>8);r[t>>>5]|=128<<t%32,r[14+(64+t>>>9<<4)]=t;for(var s=p._ff,c=p._gg,l=p._hh,f=p._ii,u=0;u<r.length;u+=16){var h=n,d=o,y=i,b=a,n=s(n,o,i,a,r[u+0],7,-680876936),a=s(a,n,o,i,r[u+1],12,-389564586),i=s(i,a,n,o,r[u+2],17,606105819),o=s(o,i,a,n,r[u+3],22,-1044525330);n=s(n,o,i,a,r[u+4],7,-176418897),a=s(a,n,o,i,r[u+5],12,1200080426),i=s(i,a,n,o,r[u+6],17,-1473231341),o=s(o,i,a,n,r[u+7],22,-45705983),n=s(n,o,i,a,r[u+8],7,1770035416),a=s(a,n,o,i,r[u+9],12,-1958414417),i=s(i,a,n,o,r[u+10],17,-42063),o=s(o,i,a,n,r[u+11],22,-1990404162),n=s(n,o,i,a,r[u+12],7,1804603682),a=s(a,n,o,i,r[u+13],12,-40341101),i=s(i,a,n,o,r[u+14],17,-1502002290),n=c(n,o=s(o,i,a,n,r[u+15],22,1236535329),i,a,r[u+1],5,-165796510),a=c(a,n,o,i,r[u+6],9,-1069501632),i=c(i,a,n,o,r[u+11],14,643717713),o=c(o,i,a,n,r[u+0],20,-373897302),n=c(n,o,i,a,r[u+5],5,-701558691),a=c(a,n,o,i,r[u+10],9,38016083),i=c(i,a,n,o,r[u+15],14,-660478335),o=c(o,i,a,n,r[u+4],20,-405537848),n=c(n,o,i,a,r[u+9],5,568446438),a=c(a,n,o,i,r[u+14],9,-1019803690),i=c(i,a,n,o,r[u+3],14,-187363961),o=c(o,i,a,n,r[u+8],20,1163531501),n=c(n,o,i,a,r[u+13],5,-1444681467),a=c(a,n,o,i,r[u+2],9,-51403784),i=c(i,a,n,o,r[u+7],14,1735328473),n=l(n,o=c(o,i,a,n,r[u+12],20,-1926607734),i,a,r[u+5],4,-378558),a=l(a,n,o,i,r[u+8],11,-2022574463),i=l(i,a,n,o,r[u+11],16,1839030562),o=l(o,i,a,n,r[u+14],23,-35309556),n=l(n,o,i,a,r[u+1],4,-1530992060),a=l(a,n,o,i,r[u+4],11,1272893353),i=l(i,a,n,o,r[u+7],16,-155497632),o=l(o,i,a,n,r[u+10],23,-1094730640),n=l(n,o,i,a,r[u+13],4,681279174),a=l(a,n,o,i,r[u+0],11,-358537222),i=l(i,a,n,o,r[u+3],16,-722521979),o=l(o,i,a,n,r[u+6],23,76029189),n=l(n,o,i,a,r[u+9],4,-640364487),a=l(a,n,o,i,r[u+12],11,-421815835),i=l(i,a,n,o,r[u+15],16,530742520),n=f(n,o=l(o,i,a,n,r[u+2],23,-995338651),i,a,r[u+0],6,-198630844),a=f(a,n,o,i,r[u+7],10,1126891415),i=f(i,a,n,o,r[u+14],15,-1416354905),o=f(o,i,a,n,r[u+5],21,-57434055),n=f(n,o,i,a,r[u+12],6,1700485571),a=f(a,n,o,i,r[u+3],10,-1894986606),i=f(i,a,n,o,r[u+10],15,-1051523),o=f(o,i,a,n,r[u+1],21,-2054922799),n=f(n,o,i,a,r[u+8],6,1873313359),a=f(a,n,o,i,r[u+15],10,-30611744),i=f(i,a,n,o,r[u+6],15,-1560198380),o=f(o,i,a,n,r[u+13],21,1309151649),n=f(n,o,i,a,r[u+4],6,-145523070),a=f(a,n,o,i,r[u+11],10,-1120210379),i=f(i,a,n,o,r[u+2],15,718787259),o=f(o,i,a,n,r[u+9],21,-343485551),n=n+h>>>0,o=o+d>>>0,i=i+y>>>0,a=a+b>>>0}return g.endian([n,o,i,a])}var g,m,v,w;g=a,m=h.utf8,v=i,w=h.bin,p._ff=function(t,e,r,n,o,i,a){a=t+(e&r|~e&n)+(o>>>0)+a;return(a<<i|a>>>32-i)+e},p._gg=function(t,e,r,n,o,i,a){a=t+(e&n|r&~n)+(o>>>0)+a;return(a<<i|a>>>32-i)+e},p._hh=function(t,e,r,n,o,i,a){a=t+(e^r^n)+(o>>>0)+a;return(a<<i|a>>>32-i)+e},p._ii=function(t,e,r,n,o,i,a){a=t+(r^(e|~n))+(o>>>0)+a;return(a<<i|a>>>32-i)+e},p._blocksize=16,p._digestsize=16,t.exports=function(t,e){if(null==t)throw new Error("Illegal argument "+t);t=g.wordsToBytes(p(t,e));return e&&e.asBytes?t:e&&e.asString?w.bytesToString(t):g.bytesToHex(t)}}),b="3.7.2",p="function"==typeof atob,g="function"==typeof btoa,m="function"==typeof Buffer;const v="function"==typeof TextDecoder?new TextDecoder:void 0,w="function"==typeof TextEncoder?new TextEncoder:void 0;const A=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),x=(t=>{let r={};return t.forEach((t,e)=>r[t]=e),r})(A),S=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,T=String.fromCharCode.bind(String),P="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(t,e=t=>t)=>new Uint8Array(Array.prototype.slice.call(t,0).map(e)),B=t=>t.replace(/=/g,"").replace(/[+\/]/g,t=>"+"==t?"-":"_"),C=t=>t.replace(/[^A-Za-z0-9\+\/]/g,"");var j=e=>{let r,n,o,i,a="";var t=e.length%3;for(let t=0;t<e.length;){if(255<(n=e.charCodeAt(t++))||255<(o=e.charCodeAt(t++))||255<(i=e.charCodeAt(t++)))throw new TypeError("invalid character found");r=n<<16|o<<8|i,a+=A[r>>18&63]+A[r>>12&63]+A[r>>6&63]+A[63&r]}return t?a.slice(0,t-3)+"===".substring(t):a};const U=g?t=>btoa(t):m?t=>Buffer.from(t,"binary").toString("base64"):j,R=m?t=>Buffer.from(t).toString("base64"):r=>{let n=[];for(let t=0,e=r.length;t<e;t+=4096)n.push(T.apply(null,r.subarray(t,t+4096)));return U(n.join(""))},O=(t,e=!1)=>e?B(R(t)):R(t),E=t=>{if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?T(192|e>>>6)+T(128|63&e):T(224|e>>>12&15)+T(128|e>>>6&63)+T(128|63&e);var e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return T(240|e>>>18&7)+T(128|e>>>12&63)+T(128|e>>>6&63)+T(128|63&e)},I=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,_=t=>t.replace(I,E),F=m?t=>Buffer.from(t,"utf8").toString("base64"):w?t=>R(w.encode(t)):t=>U(_(t)),k=(t,e=!1)=>e?B(F(t)):F(t);var z=t=>k(t,!0);const D=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,L=t=>{switch(t.length){case 4:var e=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return T(55296+(e>>>10))+T(56320+(1023&e));case 3:return T((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return T((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},W=t=>t.replace(D,L);g=e=>{if(e=e.replace(/\s+/g,""),!S.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let r,n="",o,i;for(let t=0;t<e.length;)r=x[e.charAt(t++)]<<18|x[e.charAt(t++)]<<12|(o=x[e.charAt(t++)])<<6|(i=x[e.charAt(t++)]),n+=64===o?T(r>>16&255):64===i?T(r>>16&255,r>>8&255):T(r>>16&255,r>>8&255,255&r);return n};const M=p?t=>atob(C(t)):m?t=>Buffer.from(t,"base64").toString("binary"):g,Z=m?t=>P(Buffer.from(t,"base64")):t=>P(M(t),t=>t.charCodeAt(0)),N=t=>Z(q(t)),Q=m?t=>Buffer.from(t,"base64").toString("utf8"):v?t=>v.decode(Z(t)):t=>W(M(t)),q=t=>C(t.replace(/[-_]/g,t=>"-"==t?"+":"/")),H=t=>Q(q(t));function V(){var t=(t,e)=>Object.defineProperty(String.prototype,t,G(e));t("fromBase64",function(){return H(this)}),t("toBase64",function(t){return k(this,t)}),t("toBase64URI",function(){return k(this,!0)}),t("toBase64URL",function(){return k(this,!0)}),t("toUint8Array",function(){return N(this)})}function $(){var t=(t,e)=>Object.defineProperty(Uint8Array.prototype,t,G(e));t("toBase64",function(t){return O(this,t)}),t("toBase64URI",function(){return O(this,!0)}),t("toBase64URL",function(){return O(this,!0)})}const G=t=>({value:t,enumerable:!1,writable:!0,configurable:!0});const J={version:b,VERSION:"3.7.2",atob:M,atobPolyfill:g,btoa:U,btoaPolyfill:j,fromBase64:H,toBase64:k,encode:k,encodeURI:z,encodeURL:z,utob:_,btou:W,decode:H,isValid:t=>{if("string"!=typeof t)return!1;t=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},fromUint8Array:O,toUint8Array:N,extendString:V,extendUint8Array:$,extendBuiltins:()=>{V(),$()}};var K=/^(?:[a-z\d\-_]{1,62}\.){0,125}(?:[a-z\d](?:\-(?=\-*[a-z\d])|[a-z]|\d){0,62}\.)[a-z\d]{1,63}$/i,X={1:75,2:50,3:35,4:23,5:20},Y=[1,2,3,4,5],tt={domain:null,useHTTPS:!0,includeLibraryParam:!0,urlPrefix:"https://",secureURLToken:null};function et(t,e){if(!Number.isInteger(t)||!Number.isInteger(e)||t<=0||e<=0||e<t)throw new Error("The min and max srcset widths can only be passed positive Number values, and min must be less than max. Found min: ".concat(t," and max: ").concat(e,"."))}function rt(t){if("number"!=typeof t||t<.01)throw new Error("The srcset widthTolerance must be a number greater than or equal to 0.01")}return function(){function u(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};if(!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),this.settings=s(s({},tt),t),this.targetWidthsCache={},"string"!=typeof this.settings.domain)throw new Error("ImgixClient must be passed a valid string domain");if(null==K.exec(this.settings.domain))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.includeLibraryParam&&(this.settings.libraryParam="js-"+u.version()),this.settings.urlPrefix=this.settings.useHTTPS?"https://":"http://"}var t,e,r;return t=u,r=[{key:"version",value:function(){return"3.4.0"}},{key:"targetWidths",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8192,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.08,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=Math.floor(t),i=Math.floor(e);et(t,e),rt(r);e=r+"/"+o+"/"+i;if(e in n)return n[e];if(o===i)return[o];for(var a=[],u=o;u<i;)a.push(Math.round(u)),u*=1+2*r;return a[a.length-1]<i&&a.push(i),n[e]=a}}],(e=[{key:"buildURL",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=this._sanitizePath(t),e=this._buildParams(e);return this.settings.secureURLToken&&(e=this._signParams(t,e)),this.settings.urlPrefix+this.settings.domain+t+e}},{key:"_buildParams",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=[].concat(f(this.settings.libraryParam?["ixlib=".concat(this.settings.libraryParam)]:[]),f(Object.entries(t).reduce(function(t,e){var r=l(e,2),n=r[0],e=r[1];if(null==e)return t;r=encodeURIComponent(n),e="64"===n.substr(-2)?J.encodeURI(e):encodeURIComponent(e);return t.push("".concat(r,"=").concat(e)),t},[])));return"".concat(0<t.length?"?":"").concat(t.join("&"))}},{key:"_signParams",value:function(t,e){t=this.settings.secureURLToken+t+e,t=y(t);return 0<e.length?e+"&s="+t:"?s="+t}},{key:"_sanitizePath",value:function(t){var t=t.replace(/^\//,"");return"/"+(t=/^https?:\/\//.test(t)?encodeURIComponent(t):encodeURI(t).replace(/[#?:+]/g,encodeURIComponent))}},{key:"buildSrcSet",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},n=e.w,o=e.h;return n||o?this._buildDPRSrcSet(t,e,r):this._buildSrcSetPairs(t,e,r)}},{key:"_buildSrcSetPairs",value:function(e,r,t){var n=this,o=l((o=void 0!==(a=t).widthTolerance?(rt(a.widthTolerance),a.widthTolerance):.08,i=void 0===a.minWidth?100:a.minWidth,a=void 0===a.maxWidth?8192:a.maxWidth,100==i&&8192==a||et(i,a),[o,i,a]),3),i=o[0],a=o[1],o=o[2],i=t.widths?(function(t){if(!Array.isArray(t)||!t.length)throw new Error("The widths argument can only be passed a valid non-empty array of integers");if(!t.every(function(t){return Number.isInteger(t)&&0<t}))throw new Error("A custom widths argument can only contain positive integer values")}(t.widths),f(t.widths)):u.targetWidths(a,o,i,this.targetWidthsCache);return i.map(function(t){return"".concat(n.buildURL(e,s(s({},r),{},{w:t}))," ").concat(t,"w")}).join(",\n")}},{key:"_buildDPRSrcSet",value:function(r,n,t){var o=this;t.devicePixelRatios&&function(t){if(!Array.isArray(t)||!t.length)throw new Error("The devicePixelRatios argument can only be passed a valid non-empty array of integers");if(!t.every(function(t){return"number"==typeof t&&1<=t&&t<=5}))throw new Error("The devicePixelRatios argument can only contain positive integer values between 1 and 5")}(t.devicePixelRatios);var e=t.devicePixelRatios||Y,i=t.disableVariableQuality||!1;i||function(t){if("boolean"!=typeof t)throw new Error("The disableVariableQuality argument can only be passed a Boolean value")}(i),t.variableQualities&&function(t){if("object"!==c(t))throw new Error("The variableQualities argument can only be an object")}(t.variableQualities);var a=s(s({},X),t.variableQualities);return(i?e.map(function(t){return"".concat(o.buildURL(r,s(s({},n),{},{dpr:t}))," ").concat(t,"x")}):e.map(function(t){return e=n,t=t,"".concat(o.buildURL(r,s(s({},e),{},{dpr:t,q:e.q||a[t]||a[Math.floor(t)]}))," ").concat(t,"x");var e})).join(",\n")}}])&&n(t.prototype,e),r&&n(t,r),u}()}); | ||
| !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ImgixClient=e()}(this,function(){"use strict";function i(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function c(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?i(Object(o),!0).forEach(function(t){var e,r;e=n,r=o[t=t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,u=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(u)throw o}}return i}}(t,e)||y(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||y(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(r="Object"===r&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function b(t,e){return t(e={exports:{}},e.exports),e.exports}function A(t){return null!=t&&(p(t)||"function"==typeof(e=t).readFloatLE&&"function"==typeof e.slice&&p(e.slice(0,0))||!!t._isBuffer);var e}var x=b(function(t){var i,r;i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(t,e){return t<<e|t>>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&r.rotl(t,8)|4278255360&r.rotl(t,24);for(var e=0;e<t.length;e++)t[e]=r.endian(t[e]);return t},randomBytes:function(t){for(var e=[];0<t;t--)e.push(Math.floor(256*Math.random()));return e},bytesToWords:function(t){for(var e=[],r=0,n=0;r<t.length;r++,n+=8)e[n>>>5]|=t[r]<<24-n%32;return e},wordsToBytes:function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},bytesToHex:function(t){for(var e=[],r=0;r<t.length;r++)e.push((t[r]>>>4).toString(16)),e.push((15&t[r]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],r=0;r<t.length;r+=2)e.push(parseInt(t.substr(r,2),16));return e},bytesToBase64:function(t){for(var e=[],r=0;r<t.length;r+=3)for(var n=t[r]<<16|t[r+1]<<8|t[r+2],o=0;o<4;o++)8*r+6*o<=8*t.length?e.push(i.charAt(n>>>6*(3-o)&63)):e.push("=");return e.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],r=0,n=0;r<t.length;n=++r%4)0!=n&&e.push((i.indexOf(t.charAt(r-1))&Math.pow(2,-2*n+8)-1)<<2*n|i.indexOf(t.charAt(r))>>>6-2*n);return e}},t.exports=r}),g={utf8:{stringToBytes:function(t){return g.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(g.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e},bytesToString:function(t){for(var e=[],r=0;r<t.length;r++)e.push(String.fromCharCode(t[r]));return e.join("")}}},P=g;function p(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var v=b(function(t){function g(l,f){l.constructor==String?l=(f&&"binary"===f.encoding?w:v).stringToBytes(l):m(l)?l=Array.prototype.slice.call(l,0):Array.isArray(l)||(l=l.toString());for(var t=p.bytesToWords(l),f=8*l.length,e=1732584193,r=-271733879,n=-1732584194,o=271733878,i=0;i<t.length;i++)t[i]=16711935&(t[i]<<8|t[i]>>>24)|4278255360&(t[i]<<24|t[i]>>>8);t[f>>>5]|=128<<f%32,t[14+(64+f>>>9<<4)]=f;for(var a=g._ff,u=g._gg,s=g._hh,c=g._ii,i=0;i<t.length;i+=16){var d=e,h=r,y=n,b=o,e=a(e,r,n,o,t[i+0],7,-680876936),o=a(o,e,r,n,t[i+1],12,-389564586),n=a(n,o,e,r,t[i+2],17,606105819),r=a(r,n,o,e,t[i+3],22,-1044525330);e=a(e,r,n,o,t[i+4],7,-176418897),o=a(o,e,r,n,t[i+5],12,1200080426),n=a(n,o,e,r,t[i+6],17,-1473231341),r=a(r,n,o,e,t[i+7],22,-45705983),e=a(e,r,n,o,t[i+8],7,1770035416),o=a(o,e,r,n,t[i+9],12,-1958414417),n=a(n,o,e,r,t[i+10],17,-42063),r=a(r,n,o,e,t[i+11],22,-1990404162),e=a(e,r,n,o,t[i+12],7,1804603682),o=a(o,e,r,n,t[i+13],12,-40341101),n=a(n,o,e,r,t[i+14],17,-1502002290),e=u(e,r=a(r,n,o,e,t[i+15],22,1236535329),n,o,t[i+1],5,-165796510),o=u(o,e,r,n,t[i+6],9,-1069501632),n=u(n,o,e,r,t[i+11],14,643717713),r=u(r,n,o,e,t[i+0],20,-373897302),e=u(e,r,n,o,t[i+5],5,-701558691),o=u(o,e,r,n,t[i+10],9,38016083),n=u(n,o,e,r,t[i+15],14,-660478335),r=u(r,n,o,e,t[i+4],20,-405537848),e=u(e,r,n,o,t[i+9],5,568446438),o=u(o,e,r,n,t[i+14],9,-1019803690),n=u(n,o,e,r,t[i+3],14,-187363961),r=u(r,n,o,e,t[i+8],20,1163531501),e=u(e,r,n,o,t[i+13],5,-1444681467),o=u(o,e,r,n,t[i+2],9,-51403784),n=u(n,o,e,r,t[i+7],14,1735328473),e=s(e,r=u(r,n,o,e,t[i+12],20,-1926607734),n,o,t[i+5],4,-378558),o=s(o,e,r,n,t[i+8],11,-2022574463),n=s(n,o,e,r,t[i+11],16,1839030562),r=s(r,n,o,e,t[i+14],23,-35309556),e=s(e,r,n,o,t[i+1],4,-1530992060),o=s(o,e,r,n,t[i+4],11,1272893353),n=s(n,o,e,r,t[i+7],16,-155497632),r=s(r,n,o,e,t[i+10],23,-1094730640),e=s(e,r,n,o,t[i+13],4,681279174),o=s(o,e,r,n,t[i+0],11,-358537222),n=s(n,o,e,r,t[i+3],16,-722521979),r=s(r,n,o,e,t[i+6],23,76029189),e=s(e,r,n,o,t[i+9],4,-640364487),o=s(o,e,r,n,t[i+12],11,-421815835),n=s(n,o,e,r,t[i+15],16,530742520),e=c(e,r=s(r,n,o,e,t[i+2],23,-995338651),n,o,t[i+0],6,-198630844),o=c(o,e,r,n,t[i+7],10,1126891415),n=c(n,o,e,r,t[i+14],15,-1416354905),r=c(r,n,o,e,t[i+5],21,-57434055),e=c(e,r,n,o,t[i+12],6,1700485571),o=c(o,e,r,n,t[i+3],10,-1894986606),n=c(n,o,e,r,t[i+10],15,-1051523),r=c(r,n,o,e,t[i+1],21,-2054922799),e=c(e,r,n,o,t[i+8],6,1873313359),o=c(o,e,r,n,t[i+15],10,-30611744),n=c(n,o,e,r,t[i+6],15,-1560198380),r=c(r,n,o,e,t[i+13],21,1309151649),e=c(e,r,n,o,t[i+4],6,-145523070),o=c(o,e,r,n,t[i+11],10,-1120210379),n=c(n,o,e,r,t[i+2],15,718787259),r=c(r,n,o,e,t[i+9],21,-343485551),e=e+d>>>0,r=r+h>>>0,n=n+y>>>0,o=o+b>>>0}return p.endian([e,r,n,o])}var p,v,m,w;p=x,v=P.utf8,m=A,w=P.bin,g._ff=function(t,e,r,n,o,i,a){t=t+(e&r|~e&n)+(o>>>0)+a;return(t<<i|t>>>32-i)+e},g._gg=function(t,e,r,n,o,i,a){t=t+(e&n|r&~n)+(o>>>0)+a;return(t<<i|t>>>32-i)+e},g._hh=function(t,e,r,n,o,i,a){t=t+(e^r^n)+(o>>>0)+a;return(t<<i|t>>>32-i)+e},g._ii=function(t,e,r,n,o,i,a){t=t+(r^(e|~n))+(o>>>0)+a;return(t<<i|t>>>32-i)+e},g._blocksize=16,g._digestsize=16,t.exports=function(t,e){if(null==t)throw new Error("Illegal argument "+t);t=p.wordsToBytes(g(t,e));return e&&e.asBytes?t:e&&e.asString?w.bytesToString(t):p.bytesToHex(t)}}),m="3.7.2",w="function"==typeof atob,t="function"==typeof btoa,e="function"==typeof Buffer;const S="function"==typeof TextDecoder?new TextDecoder:void 0,T="function"==typeof TextEncoder?new TextEncoder:void 0;const u=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),a=(t=>{let r={};return t.forEach((t,e)=>r[t]=e),r})(u),B=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,s=String.fromCharCode.bind(String),C="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(t,e=t=>t)=>new Uint8Array(Array.prototype.slice.call(t,0).map(e)),j=t=>t.replace(/=/g,"").replace(/[+\/]/g,t=>"+"==t?"-":"_"),E=t=>t.replace(/[^A-Za-z0-9\+\/]/g,"");var U=e=>{let r,n,o,i,a="";var t=e.length%3;for(let t=0;t<e.length;){if(255<(n=e.charCodeAt(t++))||255<(o=e.charCodeAt(t++))||255<(i=e.charCodeAt(t++)))throw new TypeError("invalid character found");r=n<<16|o<<8|i,a+=u[r>>18&63]+u[r>>12&63]+u[r>>6&63]+u[63&r]}return t?a.slice(0,t-3)+"===".substring(t):a};const R=t?t=>btoa(t):e?t=>Buffer.from(t,"binary").toString("base64"):U,O=e?t=>Buffer.from(t).toString("base64"):r=>{let n=[];for(let t=0,e=r.length;t<e;t+=4096)n.push(s.apply(null,r.subarray(t,t+4096)));return R(n.join(""))},r=(t,e=!1)=>e?j(O(t)):O(t),I=t=>{var e;return t.length<2?(e=t.charCodeAt(0))<128?t:e<2048?s(192|e>>>6)+s(128|63&e):s(224|e>>>12&15)+s(128|e>>>6&63)+s(128|63&e):(e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320),s(240|e>>>18&7)+s(128|e>>>12&63)+s(128|e>>>6&63)+s(128|63&e))},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,F=t=>t.replace(_,I),k=e?t=>Buffer.from(t,"utf8").toString("base64"):T?t=>O(T.encode(t)):t=>R(F(t)),o=(t,e=!1)=>e?j(k(t)):k(t);t=t=>o(t,!0);const z=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,D=t=>{switch(t.length){case 4:var e=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return s(55296+(e>>>10))+s(56320+(1023&e));case 3:return s((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return s((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},L=t=>t.replace(z,D);var W=e=>{if(e=e.replace(/\s+/g,""),!B.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let r,n="",o,i;for(let t=0;t<e.length;)r=a[e.charAt(t++)]<<18|a[e.charAt(t++)]<<12|(o=a[e.charAt(t++)])<<6|(i=a[e.charAt(t++)]),n+=64===o?s(r>>16&255):64===i?s(r>>16&255,r>>8&255):s(r>>16&255,r>>8&255,255&r);return n};const M=w?t=>atob(E(t)):e?t=>Buffer.from(t,"base64").toString("binary"):W,Z=e?t=>C(Buffer.from(t,"base64")):t=>C(M(t),t=>t.charCodeAt(0)),N=t=>Z(q(t)),Q=e?t=>Buffer.from(t,"base64").toString("utf8"):S?t=>S.decode(Z(t)):t=>L(M(t)),q=t=>E(t.replace(/[-_]/g,t=>"-"==t?"+":"/")),H=t=>Q(q(t));function V(){var t=(t,e)=>Object.defineProperty(String.prototype,t,G(e));t("fromBase64",function(){return H(this)}),t("toBase64",function(t){return o(this,t)}),t("toBase64URI",function(){return o(this,!0)}),t("toBase64URL",function(){return o(this,!0)}),t("toUint8Array",function(){return N(this)})}function $(){var t=(t,e)=>Object.defineProperty(Uint8Array.prototype,t,G(e));t("toBase64",function(t){return r(this,t)}),t("toBase64URI",function(){return r(this,!0)}),t("toBase64URL",function(){return r(this,!0)})}const G=t=>({value:t,enumerable:!1,writable:!0,configurable:!0});const J={version:m,VERSION:"3.7.2",atob:M,atobPolyfill:W,btoa:R,btoaPolyfill:U,fromBase64:H,toBase64:o,encode:o,encodeURI:t,encodeURL:t,utob:F,btou:L,decode:H,isValid:t=>{if("string"!=typeof t)return!1;t=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},fromUint8Array:r,toUint8Array:N,extendString:V,extendUint8Array:$,extendBuiltins:()=>{V(),$()}};var K=/^(?:[a-z\d\-_]{1,62}\.){0,125}(?:[a-z\d](?:\-(?=\-*[a-z\d])|[a-z]|\d){0,62}\.)[a-z\d]{1,63}$/i,X={1:75,2:50,3:35,4:23,5:20},Y=[1,2,3,4,5],tt={domain:null,useHTTPS:!0,includeLibraryParam:!0,urlPrefix:"https://",secureURLToken:null};function et(t,e){if(!Number.isInteger(t)||!Number.isInteger(e)||t<=0||e<=0||e<t)throw new Error("The min and max srcset widths can only be passed positive Number values, and min must be less than max. Found min: ".concat(t," and max: ").concat(e,"."))}function rt(t){if("number"!=typeof t||t<.01)throw new Error("The srcset widthTolerance must be a number greater than or equal to 0.01")}return function(){function s(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=this,r=s;if(!(e instanceof r))throw new TypeError("Cannot call a class as a function");if(this.settings=c(c({},tt),t),this.targetWidthsCache={},"string"!=typeof this.settings.domain)throw new Error("ImgixClient must be passed a valid string domain");if(null==K.exec(this.settings.domain))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.includeLibraryParam&&(this.settings.libraryParam="js-"+s.version()),this.settings.urlPrefix=this.settings.useHTTPS?"https://":"http://"}var t,e,r;return t=s,r=[{key:"version",value:function(){return"3.5.0"}},{key:"targetWidths",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:100,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:8192,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.08,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=Math.floor(t),i=Math.floor(e),t=(et(t,e),rt(r),r+"/"+o+"/"+i);if(t in n)return n[t];if(o===i)return[o];for(var a=[],u=o;u<i;)a.push(Math.round(u)),u*=1+2*r;return a[a.length-1]<i&&a.push(i),n[t]=a}}],(e=[{key:"buildURL",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=this._sanitizePath(t,{encode:!(2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}).disablePathEncoding}),e=this._buildParams(e);return this.settings.secureURLToken&&(e=this._signParams(t,e)),this.settings.urlPrefix+this.settings.domain+t+e}},{key:"_buildParams",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=[].concat(l(this.settings.libraryParam?["ixlib=".concat(this.settings.libraryParam)]:[]),l(Object.entries(t).reduce(function(t,e){var e=h(e,2),r=e[0],e=e[1];if(null==e)return t;var n=encodeURIComponent(r),r="64"===r.substr(-2)?J.encodeURI(e):encodeURIComponent(e);return t.push("".concat(n,"=").concat(r)),t},[])));return"".concat(0<t.length?"?":"").concat(t.join("&"))}},{key:"_signParams",value:function(t,e){t=this.settings.secureURLToken+t+e,t=v(t);return 0<e.length?e+"&s="+t:"?s="+t}},{key:"_sanitizePath",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=t.replace(/^\//,"");return"/"+(t=!1!==e.encode?/^https?:\/\//.test(t)?encodeURIComponent(t):encodeURI(t).replace(/[#?:+]/g,encodeURIComponent):t)}},{key:"buildSrcSet",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},n=e.w,o=e.h;return n||o?this._buildDPRSrcSet(t,e,r):this._buildSrcSetPairs(t,e,r)}},{key:"_buildSrcSetPairs",value:function(e){var r=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};t=void 0!==(a=o).widthTolerance?(rt(a.widthTolerance),a.widthTolerance):.08,i=void 0===a.minWidth?100:a.minWidth,a=void 0===a.maxWidth?8192:a.maxWidth,100==i&&8192==a||et(i,a);var t=h([t,i,a],3),i=t[0],a=t[1],t=t[2];if(o.widths){var u=o.widths;if(!Array.isArray(u)||!u.length)throw new Error("The widths argument can only be passed a valid non-empty array of integers");if(!u.every(function(t){return Number.isInteger(t)&&0<t}))throw new Error("A custom widths argument can only contain positive integer values");u=l(o.widths)}else u=s.targetWidths(a,t,i,this.targetWidthsCache);return u.map(function(t){return"".concat(r.buildURL(e,c(c({},n),{},{w:t}),{disablePathEncoding:o.disablePathEncoding})," ").concat(t,"w")}).join(",\n")}},{key:"_buildDPRSrcSet",value:function(r){var n=this,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(i.devicePixelRatios){var t=i.devicePixelRatios;if(!Array.isArray(t)||!t.length)throw new Error("The devicePixelRatios argument can only be passed a valid non-empty array of integers");if(!t.every(function(t){return"number"==typeof t&&1<=t&&t<=5}))throw new Error("The devicePixelRatios argument can only contain positive integer values between 1 and 5")}var t=i.devicePixelRatios||Y,e=i.disableVariableQuality||!1;if(!e){var a=e;if("boolean"!=typeof a)throw new Error("The disableVariableQuality argument can only be passed a Boolean value")}if(i.variableQualities){a=i.variableQualities;if("object"!==f(a))throw new Error("The variableQualities argument can only be an object")}var u=c(c({},X),i.variableQualities);return(e?t.map(function(t){return"".concat(n.buildURL(r,c(c({},o),{},{dpr:t}),{disablePathEncoding:i.disablePathEncoding})," ").concat(t,"x")}):t.map(function(t){return e=o,t=t,"".concat(n.buildURL(r,c(c({},e),{},{dpr:t,q:e.q||u[t]||u[Math.floor(t)]}),{disablePathEncoding:i.disablePathEncoding})," ").concat(t,"x");var e})).join(",\n")}}])&&d(t.prototype,e),r&&d(t,r),Object.defineProperty(t,"prototype",{writable:!1}),s}()}); |
+66
-51
@@ -15,10 +15,5 @@ 'use strict'; | ||
| var symbols = Object.getOwnPropertySymbols(object); | ||
| if (enumerableOnly) { | ||
| symbols = symbols.filter(function (sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| }); | ||
| } | ||
| keys.push.apply(keys, symbols); | ||
| enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| })), keys.push.apply(keys, symbols); | ||
| } | ||
@@ -31,15 +26,8 @@ | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i] != null ? arguments[i] : {}; | ||
| if (i % 2) { | ||
| ownKeys(Object(source), true).forEach(function (key) { | ||
| _defineProperty(target, key, source[key]); | ||
| }); | ||
| } else if (Object.getOwnPropertyDescriptors) { | ||
| Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
| } else { | ||
| ownKeys(Object(source)).forEach(function (key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
| var source = null != arguments[i] ? arguments[i] : {}; | ||
| i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
| _defineProperty(target, key, source[key]); | ||
| }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
@@ -53,13 +41,7 @@ | ||
| if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
| _typeof = function (obj) { | ||
| return typeof obj; | ||
| }; | ||
| } else { | ||
| _typeof = function (obj) { | ||
| return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
| }; | ||
| } | ||
| return _typeof(obj); | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
| return typeof obj; | ||
| } : function (obj) { | ||
| return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
| }, _typeof(obj); | ||
| } | ||
@@ -86,2 +68,5 @@ | ||
| if (staticProps) _defineProperties(Constructor, staticProps); | ||
| Object.defineProperty(Constructor, "prototype", { | ||
| writable: false | ||
| }); | ||
| return Constructor; | ||
@@ -181,3 +166,3 @@ } | ||
| // package version used in the ix-lib parameter | ||
| var VERSION = '3.4.0'; // regex pattern used to determine if a domain is valid | ||
| var VERSION = '3.5.0'; // regex pattern used to determine if a domain is valid | ||
@@ -302,6 +287,9 @@ 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 | ||
| value: function buildURL() { | ||
| var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var rawPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| var sanitizedPath = this._sanitizePath(path); | ||
| var path = this._sanitizePath(rawPath, { | ||
| encode: !options.disablePathEncoding | ||
| }); | ||
@@ -311,6 +299,6 @@ var finalParams = this._buildParams(params); | ||
| if (!!this.settings.secureURLToken) { | ||
| finalParams = this._signParams(sanitizedPath, finalParams); | ||
| finalParams = this._signParams(path, finalParams); | ||
| } | ||
| return this.settings.urlPrefix + this.settings.domain + sanitizedPath + finalParams; | ||
| return this.settings.urlPrefix + this.settings.domain + path + finalParams; | ||
| } | ||
@@ -341,19 +329,34 @@ }, { | ||
| var signatureBase = this.settings.secureURLToken + path + queryParams; | ||
| var signature = md5__default['default'](signatureBase); | ||
| var signature = md5__default["default"](signatureBase); | ||
| return queryParams.length > 0 ? queryParams + '&s=' + signature : '?s=' + signature; | ||
| } | ||
| /** | ||
| * "Sanitize" the path of the image URL. | ||
| * Ensures that the path has a leading slash, and that the path is correctly | ||
| * encoded. If it's a proxy path (begins with http/https), then encode the | ||
| * whole path as a URI component, otherwise only encode specific characters. | ||
| * @param {string} path The URL path of the image | ||
| * @param {Object} options Sanitization options | ||
| * @param {boolean} options.encode Whether to encode the path, default true | ||
| * @returns {string} The sanitized path | ||
| */ | ||
| }, { | ||
| key: "_sanitizePath", | ||
| value: function _sanitizePath(path) { | ||
| var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| // Strip leading slash first (we'll re-add after encoding) | ||
| var _path = path.replace(/^\//, ''); | ||
| 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.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); | ||
| } | ||
| } | ||
@@ -380,5 +383,8 @@ | ||
| key: "_buildSrcSetPairs", | ||
| value: function _buildSrcSetPairs(path, params, options) { | ||
| value: function _buildSrcSetPairs(path) { | ||
| var _this = this; | ||
| var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| var _validateAndDestructu = validateAndDestructureOptions(options), | ||
@@ -402,3 +408,5 @@ _validateAndDestructu2 = _slicedToArray(_validateAndDestructu, 3), | ||
| w: w | ||
| })), " ").concat(w, "w"); | ||
| }), { | ||
| disablePathEncoding: options.disablePathEncoding | ||
| }), " ").concat(w, "w"); | ||
| }); | ||
@@ -409,5 +417,8 @@ return srcset.join(',\n'); | ||
| key: "_buildDPRSrcSet", | ||
| value: function _buildDPRSrcSet(path, params, options) { | ||
| value: function _buildDPRSrcSet(path) { | ||
| var _this2 = this; | ||
| var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| if (options.devicePixelRatios) { | ||
@@ -434,3 +445,5 @@ validateDevicePixelRatios(options.devicePixelRatios); | ||
| q: params.q || qualities[dpr] || qualities[Math.floor(dpr)] | ||
| })), " ").concat(dpr, "x"); | ||
| }), { | ||
| disablePathEncoding: options.disablePathEncoding | ||
| }), " ").concat(dpr, "x"); | ||
| }; | ||
@@ -441,3 +454,5 @@ | ||
| dpr: dpr | ||
| })), " ").concat(dpr, "x"); | ||
| }), { | ||
| disablePathEncoding: options.disablePathEncoding | ||
| }), " ").concat(dpr, "x"); | ||
| }) : targetRatios.map(function (dpr) { | ||
@@ -444,0 +459,0 @@ return withQuality(path, params, dpr); |
+6
-1
@@ -14,3 +14,7 @@ declare class ImgixClient { | ||
| buildURL(path: string, params?: {}): string; | ||
| buildURL( | ||
| path: string, | ||
| params?: {}, | ||
| options?: { disablePathEncoding?: boolean }, | ||
| ): string; | ||
| _sanitizePath(path: string): string; | ||
@@ -42,4 +46,5 @@ _buildParams(params: {}): string; | ||
| variableQualities?: VariableQualities; | ||
| disablePathEncoding?: boolean; | ||
| } | ||
| export default ImgixClient; |
+65
-50
@@ -9,10 +9,5 @@ import md5 from 'md5'; | ||
| var symbols = Object.getOwnPropertySymbols(object); | ||
| if (enumerableOnly) { | ||
| symbols = symbols.filter(function (sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| }); | ||
| } | ||
| keys.push.apply(keys, symbols); | ||
| enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| })), keys.push.apply(keys, symbols); | ||
| } | ||
@@ -25,15 +20,8 @@ | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i] != null ? arguments[i] : {}; | ||
| if (i % 2) { | ||
| ownKeys(Object(source), true).forEach(function (key) { | ||
| _defineProperty(target, key, source[key]); | ||
| }); | ||
| } else if (Object.getOwnPropertyDescriptors) { | ||
| Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
| } else { | ||
| ownKeys(Object(source)).forEach(function (key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
| var source = null != arguments[i] ? arguments[i] : {}; | ||
| i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
| _defineProperty(target, key, source[key]); | ||
| }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
@@ -47,13 +35,7 @@ | ||
| if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
| _typeof = function (obj) { | ||
| return typeof obj; | ||
| }; | ||
| } else { | ||
| _typeof = function (obj) { | ||
| return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
| }; | ||
| } | ||
| return _typeof(obj); | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
| return typeof obj; | ||
| } : function (obj) { | ||
| return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
| }, _typeof(obj); | ||
| } | ||
@@ -80,2 +62,5 @@ | ||
| if (staticProps) _defineProperties(Constructor, staticProps); | ||
| Object.defineProperty(Constructor, "prototype", { | ||
| writable: false | ||
| }); | ||
| return Constructor; | ||
@@ -175,3 +160,3 @@ } | ||
| // package version used in the ix-lib parameter | ||
| var VERSION = '3.4.0'; // regex pattern used to determine if a domain is valid | ||
| var VERSION = '3.5.0'; // regex pattern used to determine if a domain is valid | ||
@@ -296,6 +281,9 @@ 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 | ||
| value: function buildURL() { | ||
| var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var rawPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; | ||
| var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| var sanitizedPath = this._sanitizePath(path); | ||
| var path = this._sanitizePath(rawPath, { | ||
| encode: !options.disablePathEncoding | ||
| }); | ||
@@ -305,6 +293,6 @@ var finalParams = this._buildParams(params); | ||
| if (!!this.settings.secureURLToken) { | ||
| finalParams = this._signParams(sanitizedPath, finalParams); | ||
| finalParams = this._signParams(path, finalParams); | ||
| } | ||
| return this.settings.urlPrefix + this.settings.domain + sanitizedPath + finalParams; | ||
| return this.settings.urlPrefix + this.settings.domain + path + finalParams; | ||
| } | ||
@@ -338,16 +326,31 @@ }, { | ||
| } | ||
| /** | ||
| * "Sanitize" the path of the image URL. | ||
| * Ensures that the path has a leading slash, and that the path is correctly | ||
| * encoded. If it's a proxy path (begins with http/https), then encode the | ||
| * whole path as a URI component, otherwise only encode specific characters. | ||
| * @param {string} path The URL path of the image | ||
| * @param {Object} options Sanitization options | ||
| * @param {boolean} options.encode Whether to encode the path, default true | ||
| * @returns {string} The sanitized path | ||
| */ | ||
| }, { | ||
| key: "_sanitizePath", | ||
| value: function _sanitizePath(path) { | ||
| var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| // Strip leading slash first (we'll re-add after encoding) | ||
| var _path = path.replace(/^\//, ''); | ||
| 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.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); | ||
| } | ||
| } | ||
@@ -374,5 +377,8 @@ | ||
| key: "_buildSrcSetPairs", | ||
| value: function _buildSrcSetPairs(path, params, options) { | ||
| value: function _buildSrcSetPairs(path) { | ||
| var _this = this; | ||
| var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| var _validateAndDestructu = validateAndDestructureOptions(options), | ||
@@ -396,3 +402,5 @@ _validateAndDestructu2 = _slicedToArray(_validateAndDestructu, 3), | ||
| w: w | ||
| })), " ").concat(w, "w"); | ||
| }), { | ||
| disablePathEncoding: options.disablePathEncoding | ||
| }), " ").concat(w, "w"); | ||
| }); | ||
@@ -403,5 +411,8 @@ return srcset.join(',\n'); | ||
| key: "_buildDPRSrcSet", | ||
| value: function _buildDPRSrcSet(path, params, options) { | ||
| value: function _buildDPRSrcSet(path) { | ||
| var _this2 = this; | ||
| var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| if (options.devicePixelRatios) { | ||
@@ -428,3 +439,5 @@ validateDevicePixelRatios(options.devicePixelRatios); | ||
| q: params.q || qualities[dpr] || qualities[Math.floor(dpr)] | ||
| })), " ").concat(dpr, "x"); | ||
| }), { | ||
| disablePathEncoding: options.disablePathEncoding | ||
| }), " ").concat(dpr, "x"); | ||
| }; | ||
@@ -435,3 +448,5 @@ | ||
| dpr: dpr | ||
| })), " ").concat(dpr, "x"); | ||
| }), { | ||
| disablePathEncoding: options.disablePathEncoding | ||
| }), " ").concat(dpr, "x"); | ||
| }) : targetRatios.map(function (dpr) { | ||
@@ -438,0 +453,0 @@ return withQuality(path, params, dpr); |
+15
-12
| { | ||
| "name": "@imgix/js-core", | ||
| "description": "A JavaScript client library for generating image URLs with imgix", | ||
| "version": "3.4.0", | ||
| "version": "3.5.0", | ||
| "repository": "https://github.com/imgix/js-core", | ||
@@ -15,5 +15,5 @@ "license": "BSD-2-Clause", | ||
| "devDependencies": { | ||
| "@babel/core": "7.16.0", | ||
| "@babel/preset-env": "7.16.4", | ||
| "@babel/register": "7.16.0", | ||
| "@babel/core": "7.17.5", | ||
| "@babel/preset-env": "7.16.11", | ||
| "@babel/register": "7.17.0", | ||
| "@google/semantic-release-replace-plugin": "1.1.0", | ||
@@ -27,7 +27,6 @@ "@semantic-release/changelog": "5.0.1", | ||
| "benchmark": "2.1.4", | ||
| "dtslint": "4.2.1", | ||
| "esm": "3.2.25", | ||
| "mocha": "8.4.0", | ||
| "prettier": "2.4.1", | ||
| "rollup": "2.56.3", | ||
| "prettier": "2.5.1", | ||
| "rollup": "2.66.1", | ||
| "rollup-plugin-babel": "4.4.0", | ||
@@ -38,4 +37,5 @@ "rollup-plugin-commonjs": "10.1.0", | ||
| "sinon": "12.0.1", | ||
| "typescript": "4.4.4", | ||
| "uglify-js": "3.14.4" | ||
| "tsd": "0.19.1", | ||
| "typescript": "4.5.5", | ||
| "uglify-js": "3.15.1" | ||
| }, | ||
@@ -45,3 +45,3 @@ "scripts": { | ||
| "build": "rollup -c", | ||
| "compile": "cp ./types/index.d.ts ./dist/index.d.ts", | ||
| "compile": "cp ./types/index.d.ts ./dist/index.d.ts && tsc", | ||
| "dev": "rollup -c -w", | ||
@@ -51,5 +51,5 @@ "prepare": "npm run build && npm run compile && npm run assert_version", | ||
| "pretty": "prettier --write '{src,test,types}/**/*.{js,ts}'", | ||
| "test": "mocha --require esm --recursive ./test/*.js && npm run dtslint", | ||
| "test": "mocha --require esm --recursive ./test/*.js && npm run tsd", | ||
| "test:performance": "mocha --require esm --recursive test/performance/*.js", | ||
| "dtslint": "echo Running dtslint; dtslint types", | ||
| "tsd": "echo Running tsd; tsd", | ||
| "release:dryRun": "npx node-env-run --exec 'semantic-release --dryRun'", | ||
@@ -66,2 +66,5 @@ "release:publish": "semantic-release" | ||
| ], | ||
| "tsd": { | ||
| "directory": "types" | ||
| }, | ||
| "release": { | ||
@@ -68,0 +71,0 @@ "branches": [ |
+36
-4
@@ -29,3 +29,3 @@ <!-- ix-docs-ignore --> | ||
| - [API](#api) | ||
| * [`ImgixClient.buildURL(path, params)`](#imgixclientbuildurlpath-params) | ||
| * [`ImgixClient.buildURL(path, params, options)`](#imgixclientbuildurlpath-params-options) | ||
| * [`ImgixClient.buildSrcSet(path, params, options)`](#imgixclientbuildsrcsetpath-params-options) | ||
@@ -37,2 +37,3 @@ + [Fixed Image Rendering](#fixed-image-rendering) | ||
| + [Variable Qualities](#variable-qualities) | ||
| + [Disable Path Encoding](#disable-path-encoding) | ||
| * [Web Proxy Sources](#web-proxy-sources) | ||
@@ -114,6 +115,8 @@ - [What is the `Ixlib` Param on Every Request?](#what-is-the-ixlib-param-on-every-request) | ||
| ### `ImgixClient.buildURL(path, params)` | ||
| ### `ImgixClient.buildURL(path, params, options)` | ||
| - **`path`:** String, required. A full, unencoded path to the image. This includes any additional directory information required to [locate the image](https://docs.imgix.com/setup/serving-images) within a source. | ||
| - **`params`:** Object. Any number of imgix rendering API [parameters](https://docs.imgix.com/apis/url). | ||
| - **`options`:** Object. Any number of modifiers, described below: | ||
| - [**`disablePathEncoding`**](#disable-path-encoding) | ||
@@ -152,2 +155,3 @@ Construct a single image URL by passing in the image `path` and any rendering API parameters. | ||
| - [**`variableQualities`**](#variable-qualities) | ||
| - [**`disablePathEncoding`**](#disable-path-encoding) | ||
@@ -247,4 +251,6 @@ <!-- prettier-ignore-end --> | ||
| ```html | ||
| https://testing.imgix.net/image.jpg?h=800&ar=3%3A2&fit=crop&dpr=1&s=3d754a157458402fd3e26977107ade74 1x, | ||
| https://testing.imgix.net/image.jpg?h=800&ar=3%3A2&fit=crop&dpr=2&s=a984ad1a81d24d9dd7d18195d5262c82 2x | ||
| https://testing.imgix.net/image.jpg?h=800&ar=3%3A2&fit=crop&dpr=1&s=3d754a157458402fd3e26977107ade74 | ||
| 1x, | ||
| https://testing.imgix.net/image.jpg?h=800&ar=3%3A2&fit=crop&dpr=2&s=a984ad1a81d24d9dd7d18195d5262c82 | ||
| 2x | ||
| ``` | ||
@@ -410,2 +416,28 @@ | ||
| #### Disable Path Encoding | ||
| This library will encode by default all paths passed to both `buildURL` and `buildSrcSet` methods. To disable path encoding, pass `{ disablePathEncoding: true }` to the third argument `options` of `buildURL()` or `buildSrcSet()`. | ||
| ```js | ||
| const client = new ImgixClient({ | ||
| domain: 'testing.imgix.net', | ||
| }); | ||
| const src = client.buildURL( | ||
| 'file+with%20some+crazy?things.jpg', | ||
| {}, | ||
| { disablePathEncoding: true }, | ||
| ); | ||
| console.log(src); | ||
| const srcset = client.buildSrcSet( | ||
| 'file+with%20some+crazy?things.jpg', | ||
| {}, | ||
| { disablePathEncoding: true }, | ||
| ); | ||
| console.log(srcset); | ||
| ``` | ||
| Normally this would output a src of `https://sdk-test.imgix.net/file%2Bwith%2520some%2Bcrazy%3Fthings.jpg`, but since path encoding is disabled, it will output a src of `https://sdk-test.imgix.net/file+with%20some+crazy?things.jpg`. | ||
| ### Web Proxy Sources | ||
@@ -412,0 +444,0 @@ |
+1
-1
| // package version used in the ix-lib parameter | ||
| export const VERSION = '3.4.0'; | ||
| export const VERSION = '3.5.0'; | ||
| // regex pattern used to determine if a domain is valid | ||
@@ -4,0 +4,0 @@ 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; |
+52
-30
@@ -50,15 +50,12 @@ import md5 from 'md5'; | ||
| buildURL(path = '', params = {}) { | ||
| const sanitizedPath = this._sanitizePath(path); | ||
| buildURL(rawPath = '', params = {}, options = {}) { | ||
| const path = this._sanitizePath(rawPath, { | ||
| encode: !options.disablePathEncoding, | ||
| }); | ||
| let finalParams = this._buildParams(params); | ||
| if (!!this.settings.secureURLToken) { | ||
| finalParams = this._signParams(sanitizedPath, finalParams); | ||
| finalParams = this._signParams(path, finalParams); | ||
| } | ||
| return ( | ||
| this.settings.urlPrefix + | ||
| this.settings.domain + | ||
| sanitizedPath + | ||
| finalParams | ||
| ); | ||
| return this.settings.urlPrefix + this.settings.domain + path + finalParams; | ||
| } | ||
@@ -100,14 +97,26 @@ | ||
| _sanitizePath(path) { | ||
| /** | ||
| * "Sanitize" the path of the image URL. | ||
| * Ensures that the path has a leading slash, and that the path is correctly | ||
| * encoded. If it's a proxy path (begins with http/https), then encode the | ||
| * whole path as a URI component, otherwise only encode specific characters. | ||
| * @param {string} path The URL path of the image | ||
| * @param {Object} options Sanitization options | ||
| * @param {boolean} options.encode Whether to encode the path, default true | ||
| * @returns {string} The sanitized path | ||
| */ | ||
| _sanitizePath(path, options = {}) { | ||
| // Strip leading slash first (we'll re-add after encoding) | ||
| let _path = path.replace(/^\//, ''); | ||
| 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.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); | ||
| } | ||
| } | ||
@@ -173,6 +182,5 @@ | ||
| _buildSrcSetPairs(path, params, options) { | ||
| const [widthTolerance, minWidth, maxWidth] = validateAndDestructureOptions( | ||
| options, | ||
| ); | ||
| _buildSrcSetPairs(path, params = {}, options = {}) { | ||
| const [widthTolerance, minWidth, maxWidth] = | ||
| validateAndDestructureOptions(options); | ||
@@ -193,3 +201,8 @@ let targetWidthValues; | ||
| const srcset = targetWidthValues.map( | ||
| (w) => `${this.buildURL(path, { ...params, w })} ${w}w`, | ||
| (w) => | ||
| `${this.buildURL( | ||
| path, | ||
| { ...params, w }, | ||
| { disablePathEncoding: options.disablePathEncoding }, | ||
| )} ${w}w`, | ||
| ); | ||
@@ -200,3 +213,3 @@ | ||
| _buildDPRSrcSet(path, params, options) { | ||
| _buildDPRSrcSet(path, params = {}, options = {}) { | ||
| if (options.devicePixelRatios) { | ||
@@ -221,7 +234,11 @@ validateDevicePixelRatios(options.devicePixelRatios); | ||
| const withQuality = (path, params, dpr) => { | ||
| return `${this.buildURL(path, { | ||
| ...params, | ||
| dpr: dpr, | ||
| q: params.q || qualities[dpr] || qualities[Math.floor(dpr)], | ||
| })} ${dpr}x`; | ||
| return `${this.buildURL( | ||
| path, | ||
| { | ||
| ...params, | ||
| dpr: dpr, | ||
| q: params.q || qualities[dpr] || qualities[Math.floor(dpr)], | ||
| }, | ||
| { disablePathEncoding: options.disablePathEncoding }, | ||
| )} ${dpr}x`; | ||
| }; | ||
@@ -231,3 +248,8 @@ | ||
| ? targetRatios.map( | ||
| (dpr) => `${this.buildURL(path, { ...params, dpr })} ${dpr}x`, | ||
| (dpr) => | ||
| `${this.buildURL( | ||
| path, | ||
| { ...params, dpr }, | ||
| { disablePathEncoding: options.disablePathEncoding }, | ||
| )} ${dpr}x`, | ||
| ) | ||
@@ -234,0 +256,0 @@ : targetRatios.map((dpr) => withQuality(path, params, dpr)); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
88336
6.41%1261
4.91%477
7.19%0
-100%