@lighthouse/common 4.37.0-canary-11 → 4.37.0-canary-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,7 +10,7 @@ function buildFetchUrl(url, options) {
|
|
|
10
10
|
awsS3BaseUrl,
|
|
11
11
|
cloudfrontBaseUrl = '',
|
|
12
12
|
cloudinaryBaseUrl,
|
|
13
|
-
fit,
|
|
13
|
+
fit = 'contain',
|
|
14
14
|
height,
|
|
15
15
|
width,
|
|
16
16
|
quality
|
|
@@ -25,13 +25,12 @@ function buildFetchUrl(url, options) {
|
|
|
25
25
|
if (shouldUseCloudfront) {
|
|
26
26
|
console.info('Using CloudFront base URL', cloudfrontBaseUrl);
|
|
27
27
|
const transformations = [];
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const fetchUrl = `${cloudfrontBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`;
|
|
28
|
+
if (width) transformations.push(`width=${width.toString()}`);
|
|
29
|
+
if (height) transformations.push(`height=${height.toString()}`);
|
|
30
|
+
if (quality) transformations.push(`quality=${quality.toString()}`);
|
|
31
|
+
if (fit) transformations.push(`fit=${fit.toString()}`);
|
|
32
|
+
const transformationsString = transformations.join('&');
|
|
33
|
+
const fetchUrl = `${cloudfrontBaseUrl}/${url}?${transformationsString}`;
|
|
35
34
|
return fetchUrl;
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -3,7 +3,8 @@ export function buildFetchUrl(url, options) {
|
|
|
3
3
|
_options$cloudfrontBa = options.cloudfrontBaseUrl,
|
|
4
4
|
cloudfrontBaseUrl = _options$cloudfrontBa === void 0 ? '' : _options$cloudfrontBa,
|
|
5
5
|
cloudinaryBaseUrl = options.cloudinaryBaseUrl,
|
|
6
|
-
fit = options.fit,
|
|
6
|
+
_options$fit = options.fit,
|
|
7
|
+
fit = _options$fit === void 0 ? 'contain' : _options$fit,
|
|
7
8
|
height = options.height,
|
|
8
9
|
width = options.width,
|
|
9
10
|
quality = options.quality;
|
|
@@ -17,14 +18,14 @@ export function buildFetchUrl(url, options) {
|
|
|
17
18
|
if (shouldUseCloudfront) {
|
|
18
19
|
console.info('Using CloudFront base URL', cloudfrontBaseUrl);
|
|
19
20
|
var _transformations = [];
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
if (fit) _transformations.push('c_fit');
|
|
25
|
-
_transformationsString = "".concat(_transformations.join(','), "/");
|
|
21
|
+
if (width) _transformations.push("width=".concat(width.toString()));
|
|
22
|
+
if (height) _transformations.push("height=".concat(height.toString()));
|
|
23
|
+
if (quality) _transformations.push("quality=".concat(quality.toString()));
|
|
24
|
+
if (fit) _transformations.push("fit=".concat(fit.toString()));
|
|
26
25
|
|
|
27
|
-
var
|
|
26
|
+
var _transformationsString = _transformations.join('&');
|
|
27
|
+
|
|
28
|
+
var _fetchUrl = "".concat(cloudfrontBaseUrl, "/").concat(url, "?").concat(_transformationsString);
|
|
28
29
|
|
|
29
30
|
return _fetchUrl;
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/helpers/build-fetch-url/index.js"],"names":["buildFetchUrl","url","options","awsS3BaseUrl","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","console","info","shouldUseCloudfront","includes","transformations","
|
|
1
|
+
{"version":3,"sources":["../../../src/helpers/build-fetch-url/index.js"],"names":["buildFetchUrl","url","options","awsS3BaseUrl","cloudfrontBaseUrl","cloudinaryBaseUrl","fit","height","width","quality","console","info","shouldUseCloudfront","includes","transformations","push","toString","transformationsString","join","fetchUrl"],"mappings":"AAAA,OAAO,SAASA,aAAT,CAAuBC,GAAvB,EAA4BC,OAA5B,EAAqC;AAAA,MAExCC,YAFwC,GAStCD,OATsC,CAExCC,YAFwC;AAAA,8BAStCD,OATsC,CAGxCE,iB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;AACA,MAAIG,qBAAqB,GAAG,EAA5B;AAEA,MAAIT,KAAJ,EAAWM,eAAe,CAACC,IAAhB,aAA0BP,KAAK,CAACQ,QAAN,EAA1B;AACX,MAAIT,MAAJ,EAAYO,eAAe,CAACC,IAAhB,aAA0BR,MAAM,CAACS,QAAP,EAA1B;AACZ,MAAIP,OAAJ,EAAaK,eAAe,CAACC,IAAhB,aAA0BN,OAAO,CAACO,QAAR,EAA1B;AACb,MAAIV,GAAJ,EAASQ,eAAe,CAACC,IAAhB,CAAqB,OAArB;AAETE,EAAAA,qBAAqB,aAAMH,eAAe,CAACI,IAAhB,CAAqB,GAArB,CAAN,MAArB;AAEA,MAAMC,QAAQ,aAAMd,iBAAN,cAA2BY,qBAA3B,SAAmDd,YAAnD,cAAmEF,GAAnE,CAAd;AAEA,SAAOkB,QAAP;AACD","sourcesContent":["export function buildFetchUrl(url, options) {\n const {\n awsS3BaseUrl,\n cloudfrontBaseUrl = '',\n cloudinaryBaseUrl,\n fit = 'contain',\n height,\n width,\n quality,\n } = options\n\n console.info('Building fetch URL', {\n url,\n cloudfrontBaseUrl,\n cloudinaryBaseUrl,\n })\n\n const shouldUseCloudfront =\n cloudfrontBaseUrl && cloudfrontBaseUrl.includes('.cloudfront.net')\n\n if (shouldUseCloudfront) {\n console.info('Using CloudFront base URL', cloudfrontBaseUrl)\n const transformations = []\n\n if (width) transformations.push(`width=${width.toString()}`)\n if (height) transformations.push(`height=${height.toString()}`)\n if (quality) transformations.push(`quality=${quality.toString()}`)\n if (fit) transformations.push(`fit=${fit.toString()}`)\n\n const transformationsString = transformations.join('&')\n\n const fetchUrl = `${cloudfrontBaseUrl}/${url}?${transformationsString}`\n return fetchUrl\n }\n\n const transformations = []\n let transformationsString = ''\n\n if (width) transformations.push(`w_${width.toString()}`)\n if (height) transformations.push(`h_${height.toString()}`)\n if (quality) transformations.push(`q_${quality.toString()}`)\n if (fit) transformations.push('c_fit')\n\n transformationsString = `${transformations.join(',')}/`\n\n const fetchUrl = `${cloudinaryBaseUrl}/${transformationsString}${awsS3BaseUrl}/${url}`\n\n return fetchUrl\n}\n"],"file":"index.js"}
|