fix: append px only to bare numbers in CosmoDB image sizes
The check was written /^d+/, which matches a literal d, so a unitless
width or height in an {Image} tag never got its px and was dropped as
invalid CSS. Anchor it at both ends so the 160px and 90% values the
current templates use are left as they are.
This commit is contained in:
@@ -537,11 +537,11 @@ class CosmoDbContext {
|
||||
}
|
||||
const imgStyles: string[] = [];
|
||||
if (options[0] !== '') {
|
||||
const value = /^d+/.test(options[0]) ? `${options[0]}px` : options[0];
|
||||
const value = /^\d+$/.test(options[0]) ? `${options[0]}px` : options[0];
|
||||
imgStyles.push(`width:${value}`);
|
||||
}
|
||||
if (options[1] !== '') {
|
||||
const value = /^d+/.test(options[1]) ? `${options[1]}px` : options[1];
|
||||
const value = /^\d+$/.test(options[1]) ? `${options[1]}px` : options[1];
|
||||
imgStyles.push(`height:${value}`);
|
||||
}
|
||||
const imgStyle = imgStyles.length !== 0 ? `style="${imgStyles.join(';')}" ` : '';
|
||||
|
||||
Reference in New Issue
Block a user