mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(common): remove unnecessary toString conversions (#47082)
A small refactor that removes explicit toString calls when not needed. PR Close #47082
This commit is contained in:
parent
8343133e94
commit
feb6ee8f6e
3 changed files with 5 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ function cloudflareLoaderFactory(path: string) {
|
|||
return (config: ImageLoaderConfig) => {
|
||||
let params = `format=auto`;
|
||||
if (config.width) {
|
||||
params += `,width=${config.width.toString()}`;
|
||||
params += `,width=${config.width}`;
|
||||
}
|
||||
const url = `${path}/cdn-cgi/image/${params}/${normalizeSrc(config.src)}`;
|
||||
return url;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export function imagekitLoaderFactory(path: string) {
|
|||
// https://ik.imagekit.io/demo/tr:w-300,h-300/medium_cafe_B1iTdD0C.jpg
|
||||
let params = `tr:q-auto`; // applies the "auto quality" transformation
|
||||
if (config.width) {
|
||||
params += `,w-${config.width?.toString()}`;
|
||||
params += `,w-${config.width}`;
|
||||
}
|
||||
const url = `${path}/${params}/${normalizeSrc(config.src)}`;
|
||||
return url;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ function imgixLoaderFactory(path: string) {
|
|||
const url = new URL(`${path}/${normalizeSrc(config.src)}`);
|
||||
// This setting ensures the smallest allowable format is set.
|
||||
url.searchParams.set('auto', 'format');
|
||||
config.width && url.searchParams.set('w', config.width.toString());
|
||||
if (config.width) {
|
||||
url.searchParams.set('w', config.width.toString());
|
||||
}
|
||||
return url.href;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue